Good starting point for learning Docker is to read following sections from the official Docker documentation. It is mainly a series of short tutorials, together with related documentation about syntax of commands, etc..
- Install Docker Engine
- Verify your installation
- Learn about images & containers
- Find and run the image from Docker Hub
- Build your own image by extending existing Docker container image with new
Dockerfile
Those are focusing mainly on how to get existing things from Docker Hub. Next thing to learn would be how to create things for running custom software on top of base Ubuntu Linux system image.
- Hello world in a container (and other chapters after that)
Docker container images can have custom metadata, including labels that make it possible to store details about container creation date or whether it was created for development or production environment. Note that metadata naming conventions are still under a bit of change, as new standards for naming conventions are created for needs of different types of users.
Also note that every new LABEL
adds one new layer to the Docker "onion" structure. Avoid adding too many layers, if possible (so that is easier to understand what the images contain & to keep image sizes more reasonable).
There are various different container management tools that can run Docker containers. Docker Engine can do the basic things relatively well, but might require extra tools for handling more complex setups (if there are a lot of containers to run). But for smaller environments, it can be used well by itself.
- Configuring and running Docker on various distributions
- Automatically start containers has several example scripts that could be put to right location somewhere under a
/etc/
directory.
Creation of new Docker images can also be integrated to existing build and development workflows, for example with a Maven plugin from Spotify tech team. It allows to make different software stacks easier to work with, while reducing the need of trying to manage every dependency at the same time (as what often happens when different software stacks are put to same server environment, without containers).
sudo apt-get update
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
pub 4096R/0EBFCD88 2017-02-22
Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid Docker Release (CE deb) <[email protected]>
sub 4096R/F273FCD8 2017-02-22
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce
You might want to install a specific version of Docker (especially for production usage) to make things more stable.
sudo apt-get install docker-ce=<VERSION>
sudo docker run hello-world