Liunx installation of docker 7 tutorial, liunxdocker
The following tutorial is for version 1.7.1, which requires installation of Version 12 or above. Refer to the next tutorial.
Yum install-y epel-release
Yum install docker-io # install docker
# Configuration file/etc/sysconfig/docker
Chkconfig dockeon # Add to startup
Service docker start # start the docker service
# View dockerversion with basic information
# View the docker version number, including the client, server, and dependent Go docker info
# Search for the container docker search name in full text by name. The returned data structure is similar to the user name/container name. For example: docker search tutorial
# Download the container docker pull user name/container name unless some officially recognized containers generally require the user name/container name structure to download the container
Run Hello World in the container
Use the docker run Command
The docker run Command has two parameters: one is the image name and the other is the command to be run in the image.
Like: docker run learn/tutorial echo "hello word"
Install new programs in the container
The next step is to install a simple program (ping) in the container ). The previously downloaded tutorial image is based on ubuntu, so you can use the apt-get command of ubuntu to install the ping program: apt-get install-y ping.
Note: After the apt-get command is executed, the container will stop, but the changes to the container will not be lost.
Objectives:
Install the ping program in the learn/tutorial image.
Tip:
When executing the apt-get command, you must include the-y parameter. If the-y parameter is not specified, the apt-get command enters the interaction mode. You need to enter a command to confirm it. However, in the docker environment, this interaction cannot be responded.
Correct command:
Docker run learn/tutorial apt-get install-y ping
Save changes to the container
After you modify a container (by running a command in the container), you can save the modification to the container, in this way, you can run the container from the latest status after saving. The process of saving the state in docker is called committing. It stores the difference between the old and new States and generates a new version.
Objectives:
First, use the docker ps-l command to obtain the container id after the ping command is installed. Then save the image as learn/ping.
Tip:
1. Run docker commit to view the parameter list of the command.
2. You need to specify the ID of the container to be submitted and saved. (Obtained by using the docker ps-l command)
3. You do not need to copy the complete id. Generally, the first three to four letters can be distinguished. (Press: similar to the version number in git)
Correct command:
Docker commit 698 learn/ping
Returns the id of the new image;
Docker run learn/ping baidu.com successfully executed
Publish a docker Image
Now we have verified that the new image can work normally. Next we can release it to the official index website. Remember the learn/tutorial image we first downloaded. We can also publish our own compiled image to the index page. On the one hand, we can reuse the image and share it with others.
Objectives:
Publish the learn/ping image to the index Website of docker.
Tip:
1. The docker images command can list all installed images.
2. The docker push command can publish an image to the official website.
3. You can only publish an image to your own space. This simulator logs on to the learn account.
Expected command:
$ Docker push learn/ping