What is Docker?
Docker Engine
This software service run by our operating system creates virtual "containers". Within cloud computing, it is known as a "Platform as a Service", or PaaS. We use containers to quickly deploy software in secure, isolated environments. Containers are considered a "Software as a Service", or SaaS.
Video Resource
Docker can interface directly with the Linux kernel and access the drivers that power our hardware. This allows most software to be deployed by Docker on other servers regardless of the hardware used during development.


Containers are fundamentally different than a virtual machine, but they perform a similar function. Virtual machines use a "hypervisor" to emulate hardware that can run its own operating system. This happens under the supervision of your host operating system. There is a great deal of computational overhead when emulating an entire virtual computer system.

Developers build a 'container image' that contain the complete operating system required to host the application. These images are used as a template to quickly interface with your hardware through your host operating system's kernel.

Containers can be controlled like a system service, allowing us to easily start, stop or restart them. Application data like configuration and database files are stored within a persistent volume attached to our container. Updating software is easy because everything used by the application is stored within the container image.
Docker can be used to: create virtual disk drives tied to the container that can be quickly deleted when the container is stopped; mount a directory from our host computer inside the container; or create a temporary filesystem in memory that is deleted when the container is stopped.


While creating a container, we can open access to ports that allow us to communicate with the container, as well as allow containers to communicate with each other. Containers commonly use ports to offer access to a web application interface or transmit information within databases.


Docker containers are controlled primarily through the terminal. You can run a docker container from the terminal with one command.
sudo docker run --it -d -p 80:80 --name nginx -v /srv/nginx/:/config scr.io/linuxserver/nginx:latest
This command has several important parameters that define how our container is created and then functions. This command follow the basic syntax:
sudo [[command]] [[parameters]]
Running 'sudo' tells the shell to run the command as Root – or 'super user do'. We are executing the 'docker' program to 'run' a container with the following parameters:
--it | Keeps the container's shell accessible through the terminal |
-d | Runs container in the background |
-p |
Opens a port on the container, connecting a port from the container to an external port on our host computer. This allows the service to be accessible by other computers on your network. |
--name | Name to use for the container |
-v | Links a directory or file from our host computer to the container so it can access it. |
scr.io/linuxserver/nginx:latest | The Docker image to use for creating the container |
This is the basic syntax for creating any Docker container. We can check the status of running Dicker containers by entering the command:
sudo docker ps

Docker Compose
This Docker Engine add-on that allows you to define and create new containers as well as the virtual networks connecting them. This makes it very easy to quickly pop-up containers using an easy-to-read markup language. Docker Compose can also help improve application security by defining private networks where an application can securely access other services behind-the-scenes.
services:
nginx:
image: lscr.io/linuxserver/nginx:latest
container_name: nginx
volumes:
- /srv/nginx/:/config
ports:
- 80:80
This Docker Compose snippet creates the same container as our example above. YAML follows a well-defined syntax that focuses on human readability. Portainer, a web application we will be installing, can use Docker Compose to quickly host services using our browser and a graphical interface.