What is docker?
Last updated
Last updated
Docker is a system service that allows you to create sandboxed applications that have their own network, storage, operating system and packages that can't access the host system.
This uses virtualization and various other features to allow for easy hosting and development of websites, databases and programs which can access shared networks and volumes for example the website container can access the API container in its own network.
This could be standard operating systems like Ubuntu, Python/Node library, Database programs and other frameworks that have been made by the community or companies.
Once you have downloaded an image from the registry you can use them to create as many containers as you like from them.
You can also add your own files to the container by using docker volumes that use a predefined directory or binding a directory to the host directory.
Networks allows you to connect your containers together so that they can communicate which each other and can use multiple networks.
In this example Container 1 (Web App) can access Container 2 (API) and Container 3 (Database) can only be accessed by the API container.
This is also a good way to secure your containers so that unauthorized access or requests can't access your other resources.
Stacks is a term for deploying and running multiple containers in a group using a config file to build the docker resources (Networks, Containers and Volumes)
In production you will usually create a stack which contains the frontend container, backend container and database container to run the entire setup.
Here is an example of a stack and a single container.
It will download or use the .net aspnet library version 9.0
The environment variables to set for the application.
Which volumes to use, this is a bind mount which uses files from the host system.
Restart is an optional property that lets you restart containers during unexpected failures, this example will restart on failures and retry up to 3 times.
The work directory is where to start the application and the commands used to setup and run the application when you start the container.
In this example it shows how to use networks and volumes with dependencies.
The web container depends on the database container to be started first.
The website and database containers will connect to a network so they can communicate with each other.
The database container uses a defined docker volume to store the database files.
The website uses a bind mount to load the website files from and to start in /app
The docker registry is an archive of system images that have pre-built features and tools for your container to use, you can pull images from the registry which will download them from and can be used to create and start containers with those tools.