Docker Certification Training Course : Lecture 2

sudo bash; yum install -y docker – commands for installing Docker on CentOs (sudo bash is for giving root privileges to current user)

service docker start – command for starting Docker as a service (mandatory for working with Docker)

Docker is always installed in /var/lib/docker directory

Docker Containers  are always created from Docker Images. DockerHub is a common storage of Docker Images

docker run <image name> (or docker container run <image name>) – command for running given Image

First Docker will attempt to find an Image on a local host; if Docker fails to find an Image locally, it will download an Image from the DockerHub and then create a Container based on Image

docker images – shows all Docker Images on a local host

docker ps – shows all Docker Containers running on a local host

docker ps -a – shows all Docker Containers on a local host (regardless of their state)

Docker has two editions : Community and Enterprise. Community edition is used by default. Community edition can use only common DockerHub. Enterprise edition also allows using customized Docker Hubs in local intranet.

Docker Containers do not have their own Operating System, instead they are using host Operating System environment they are launched in. That is why containers based on Operating System images (like docker run ubuntu) will immediately turn from Up into Exited state – because no processes will run inside this container.

There are different modes of creating docker containers :

  • foreground mode : not recommended for use because docker container captures current terminal session (it is a default mode, though)
  • detach mode : recommended for use since it does not capture the terminal session and runs in a background ; -d parameter should be added to docker run command for launching container in detach mode
  • interactive mode : used for entering the shell of the running container, see description below

docker ps command shows local host containers info :

  • CONTAINER_ID – whenever a user is trying to create a Container, Docker Engine assignes unique Container_ID to every Container
  • IMAGE – Docker Image that was used for creating a Container
  • COMMAND – command of the process starting inside the running container
  • CREATED – when the particular Container was created
  • STATUS – what status does Container have at the moment (Up, Exited)
  • PORTS – port(s) that Container process is using (port is binded with container, not the host machine)
  • NAMES – name given to Container by Docker Engine

See example of docker ps command output below :

docker ps command output example

Each Docker Container encapsulate their own mac address, ip address, gateway, environment configuration.

docker inspect <CONTAINER_ID> – command that shows the complete information about Docker Container

hostName -I – command that shows external and internal addresses of local host

hostname -i – command that shows only external address of local host

Note that Docker creates its own network interface on the host machine with its gateway and netmask. Docker containers are assigned ip addresses in Docker’s own network. See example below :

Docker network interface is docker0

Next

Leave a Reply

Your email address will not be published. Required fields are marked *