What’s docker?

Docker is a computer program that performs operating-system-level virtualization, also known as “containerization”.It was first released in 2013 and is developed by Docker, Inc.

Docker is used to run software packages called “containers“. Containers are isolated from each other and bundle their own application,tools, libraries and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating-system kernel and are thus more lightweight than virtual machines. Containers are created from “images” that specify their precise contents. Images are often created by combining and modifying standard images downloaded from public repositories.

Quote from wikipedia

Docker installation

Gentoo

Firstly, check your kernel. If the kernel has not been configured properly before merging the app-emulation/docker package, a list of missing kernel options will be printed by emerge. These kernel features must be enabled manually.

As for me, not really familiar with kernel menu config , I found a much easier way for me to config the kernel. Firstly I installed docker:

emerge -av app-emulation/docker

And then, I run this command to check that how to config my kernel.

/usr/share/docker/contrib/check-config.sh

After that, I edit /usr/src/linux, search and replace “XXX is not set” by “XXX=y”. XXX is everything output in check-config.sh above. If XXX cannot be found in .config, just save, make menuconfig, exit, save, and edit it again.

Then, compile the kernel and install it.

make -j9
make install modules_install

Finally, we should finish some settings (replace Bold word) :

usermod -aG docker jerry
systemctl enable docker.service
systemctl start docker.service

Other distribution

Follow this article.

Images and containers

Firstly we should know Images and containers.

An image is an executable package that includes everything needed to run an application–the code, a runtime, libraries, environment variables, and configuration files.

A container is launched by running an image, a runtime instance of an image–what the image becomes in memory when executed (that is, an image with state, or a user process). You can see a list of your running containers with the command, docker ps, just as you would in Linux.

Hello, world

To run our first docker, Firstly we should pull the image from library.

docker image pull hello-world

Then we run it. Running it will create a container file, which will not be deleted unless you remove it manually.

docker run hello-world

We can see the output:

Hello from Docker! This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

1.The Docker client contacted the Docker daemon.

2.The Docker daemon pulled the “hello-world” image from the Docker Hub.
(amd64)

3.The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.

4.The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

If you do not output like this, please reinstall your docker, there must be something wrong with it. If it workd can see containers via this command:

docker ps -a

Output will be like this table:

CONTAINER IDIMAGE COMMANDCREATED STATUSPORTSNAMES
0c220c9ac961hello-world “/hello”2 seconds agoExited (0) 2 seconds agoawesome_noether

We do not need this hello-world container fill anymore, so we can remove it easily:

docker container rm 0c220c9ac961
docker ps -a

2 Comments

Leave a Reply

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