The Docker architecture employs a client-server design. A Docker client talks to the Docker daemon via the REST API and the daemon manages the containers according to the commands issued by the user. The REST API handles communication between the client and the daemon
Let’s take a deeper look at Docker’s architecture how it runs applications in isolated containers and how it works under the hood.
Let’s start off by drawing a comparison between Containers and Virtual Machines.
Virtualization technology uses a hypervisor, an application that creates a virtualization or abstraction layer that emulates the available hardware resources including the RAM, CPU, USB ports, NICS, and many more. This makes it possible for guests or virtual machines to use them.
FROM - specifies the base(parent) image. Alpine version is the minimal docker image based on Alpine Linux which is only 5mb in size.
RUN - runs a Linux command. Used to install packages into container, create folders, etc
ENV - sets environment variables. We can have multiple variables in a single dockerfile.
COPY - copies files and directories to the container.
EXPOSE - expose ports
ENTRYPOINT - provides command and arguments for an executing container.
CMD - provides a command and arguments for an executing container. There can be only one CMD.
VOLUME - create a directory mount point to access and store persistent data.
WORKDIR - sets the working directory for the instructions that follow.
LABEL - provides metada like maintainer.
ADD - Copies files and directories to the container. Can unpack compressed files.
ARG - Define build-time variable.
Review a list of all Docker commands. There are a few commands which are little confusing. Let's have a look at them.
Both commands serve a similar purpose, to copy files into the image.
COPY - let you copy files and directories from the host.
ADD - does the same. Additionally it lets you use URL location and unzip files into image.
Docker documentation recommends using the COPY command.
CMD - allows you to set a default command which will be executed only when you run a container without specifying a command. If a Docker container runs with a command, the default command will be ignored.
ENTRYPOINT - allows you to configure a container that will run as an executable. ENTRYPOINT command and parameters are not ignored when Docker container runs with command line parameters.
Container delete command:
One: sudo docker rm container id
All: sudo docker rm -f $(sudo docker ps -a -q)
Images delete command:
One: sudo docker rmi container id
All: sudo docker image remove -f $(sudo docker images -a -q)
# Delete all unused and stop docker
sudo docker system prune
# It removes unused resources, freeing up space and keeping your system clean.
sudo docker container prune
# Cache clear
npm cache clear --force
# Ubuntu Firewall
# Show firewll
sudo ufw app list
# Allow HTTP
sudo ufw allow 'Nginx HTTP'
#Firewall status
sudo ufw status
# Firewall Active
sudo ufw enable
# Ubuntu Version Check
lsb_release -a
#ubuntu update
sudo apt-get update
# Docker Install
sudo apt install docker.io
sudo systemctl enable docker
sudo systemctl status docker
sudo systemctl start docker
# Ubuntu Dockerhub Permission
sudo chmod 666 /var/run/docker.sock