Please enable JavaScript.
Coggle requires JavaScript to display documents.
Docker Lec 28, 29, 30 - Coggle Diagram
Docker Lec 28, 29, 30
3 options to specify port
neither expose nor -p
communicate within
container
use expose only
container to container
communication within
one host
use only -p
communicate over
the internet
Docker volume is
a directory shared
between different
containers or between
containers and hosts
Can be created using
command or Dockerfile
It is only created
while creating a
new container
volumes are not
deleted when we
delete containers
Command to create
volume from Dockerfile
VOLUME ["/[volume_name]"]
Make a container
to include volume
from other container
docker run -it --priveleged=true
--volumes-from [existing_container]
[base_image] /bin/bash
Command to create
new volume when
creating new container
docker run -it -v /[new_volume]
ubuntu /bin/bash
map volume from
host to container
docker run -it -v [dir in host]:
[dir in container] --priveleged=true
ubuntu /bin/bash
some other docker
command for volume
docker volume [create|rm|inspect] [volume|container]
Expose port while
creating a container
docker run -td -p 80:80 ubuntu
8080:8080 for jenkins
if expose is used in place of -p,
the only container-container
communication will be established
while with -p, the container is
connected to host and it can
receive the network traffic via host,
Note that we have not used '/bin/bash'
here, so you have to enter the
container with 'docker exec' command
instead of 'docker attach' command
show all mapped
ports with the host
docker port [container_name]
Another command to
get into container with
new process
docker exec -it [container_name] /bin/bash
Update all packages
on ubuntu
apt-get update
install apache server
on ubuntu
apt-get install apache2
configure webpage
and apache server
cd /var/www/html
echo "Subscribe" >inddex.html
start apache server
service apache2 restart
For pushing image to docker hub
Make account on docker hub.
Login on the docker with the
account of docker hub using:
docker login
Now tag the image and
push it to docker hub using:
docker tag [image_name] [docker_id]/[new_name_image]
docker push [docker-id]/[image_name]
stop all running
containers
docker stop $(docker ps -a -q)
delete all stopped
containers
docker rm $(docker ps -a -q)
delete all images
docker rmi -f $(docker images -q)
When you delete the
container, the mapped
ports are unmapped