Skip to content
Rodrigo edited this page Oct 16, 2019 · 6 revisions

Welcome to the docker-vagrant wiki! ✏️ 📚

The aim of this wiki is show the most common tasks used on Docker 🐳.

All you need, is running Vagrant with Docker and Internet connection. Another way to get Docker, is Play With Docker.

⚠️ You need a Docker Hub account to be able to login, however, if you don't want to create a Docker Hub account with your private email, you can use a temporary email to do the practice.

If everything was fine, login via SSH:

vagrant ssh

Internal & External IP

💡 Throughout wiki, there are examples in which we expose ports outside. We can use localhost or a Web browser (Firefox, Google Chrome, Edge). So that, we need to know what IPs are assigned to VM.

  • Internal
vagrant@ubuntu-xenial:~$ ifconfig enp0s3
enp0s3    Link encap:Ethernet  HWaddr 02:af:57:b2:64:eb  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::af:57ff:feb2:64eb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:351150 errors:0 dropped:0 overruns:0 frame:0
          TX packets:31852 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:339109166 (339.1 MB)  TX bytes:2085246 (2.0 MB)
  • External
vagrant@ubuntu-xenial:~$ ifconfig enp0s8
enp0s8    Link encap:Ethernet  HWaddr 08:00:27:ff:7a:3f  
          inet addr:192.168.0.43  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feff:7a3f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1415 errors:0 dropped:0 overruns:0 frame:0
          TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:93243 (93.2 KB)  TX bytes:3518 (3.5 KB)

Example with NGINX

Run NGINX container

vagrant@ubuntu-xenial:~$ docker container run --name nginx -p 8080:80 -d nginx
821168800b370b9bb9f15070fd1a1c36f720e228371690fca7273a1ddbd57d6b
  • Localhost
vagrant@ubuntu-xenial:~$ curl localhost:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
  • Web browser