Professional Documents
Culture Documents
2nd Week - Docker Networks
2nd Week - Docker Networks
Networking
By default when installing docker you’re presented with 3 networks
$ docker inspect c1
$ docker inspect c2
You will find both of them are on the same network, probably with IP
addresses like (172.18.0.2) and (172.18.0.3)
If you try to get into one container ( $ docker attach c1 ) and then ping
the other one ( $ ping 172.18.0.3) you’d get a normal response
indicating that both containers can communicate with each other.
You can even create a new network with the type Bridge like that
Now if you try to create new containers with that new network
Indeed both networks are of type Bridge, but still .. they are 2 different
networks.
$ ping 172.19.0.3
$ ping c4
Both of them are the same .. c4 will be automatically
resolved by Docker to the corresponding container IP.
none → Self explanatory … none is used when you don’t want the
container to have any type of networking
To make sure this is running you can either inspect the container itself
or the none network
Note that other types also exist like the host, overlay, macvlan,
but those are out of the scope of this course
If you want to fine more about them please refer to the network guide.
Now what if we created a docker Image that holds all that … the app,
Dart, and the needed version of flutter.. so that friend can just get the
app up and running with a single command .. something like
OR
If you’re on the same location as the Dockerfile, you can run
docker build -t myimage:version1.0 .
4. Push the image to docker hub ( https://docs.docker.com/get-
started/04_sharing_app/ )
5. Your friend can simply then pull that image from Docker hub like
we did before
Assignment
Create a docker image that
✔ includes a program written in Java which prints your name
✔ the program should be run once a container is created using your
docker image
then push the image to your docker hub account and share the image
link to the class room (Class code: zpyntoe)
You can use any base image of your choice, doesn’t have to be
openjdk.