1. We recognize the docker is working properly, we first need to obtain the latest CentOS mirrors
$ Docker pull centos: latest
$ 2. docker images centos Docker View Mirror
[Root @ docker ~] # docker images centos
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos latest 7322fbe74aa5 6 weeks ago 172.2 MB
$ 3. docker run -i -t centos / bin / bash bash shell to run a simple test to create this image
4. Create Docker Hub account
There are two types of access can create and register a Docker Hub account:
1. Adoption of the website, or
2. Command Line
Through the website registration
Fill in the registration form, select your user name and password and set your e-mail. You can also sign up for the mailing list docker, there will be a lot of information about the docker's
Command to log DockerHub
$ Docker login
5. Run "Hellow wrold" in the Docker
6. $ Docker run centos / bin / echo 'hello world' to run the first container
7.Docker run we have run those steps specified command Docker binary we want to implement, run. docker run combined operation containers, mirroring is running centos (when specified image does not exist it will be downloaded from the public image library), and then perform run Create a container, and then tell what Docker run command \ bin \ echo in a new container, it You will see the results hello world, if Docker container input command is activated here as long as hello word output, the container will stop.
$ 8. docker run -t -i Ubuntu: 14.04 / bin / bash -t and -i. -t Flag heart vessel designated a pseudo-terminal or terminal, -i label allows us to interact STDIN container. / Bin / bash. This will start the bash shell within the container;
When you run commands finished, enter exit to exit.
9. $ docker run -d ubuntu: 14.04 / bin / sh -c "while true; do echo hello world; sleep 1; done"
docker but we specify a -d logo. -d identifies tell docker container to run in the background mode.
This is a ridiculous hello word process: a script will always output "hello word"
? Why do not we see a lot of "hello word" but a long string returned docker:
This long string called container ID. It is the unique identifier of the container, so we can use it.
Note: The container ID is a bit long and very awkward, later on we will see a breakpoint ID, in some respects it is a simplified version of the container ID.
10.docker ps command must ensure that the container is running
11. # We can use docker ps -a command to view (without concern for containers is not running). docker ps command can check all containers docker process.
12. [root @ docker ~] # docker ps -a
13.CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d162d83800cf centos: latest "/ bin / bash" 2 days ago Exited (0) 2 days ago reverent_mclean
325af222cdd9 centos: latest "/ bin / echo 'hellow w 2 days ago naughty_stallman
6452d29e7540 centos: latest "/ bin / bash echo 'hel 2 days ago Exited (126) 2 days ago adoring_mccarthy
db8321ced433 centos: latest "/ bin / bash" 2 days ago Exited (0) 2 days ago silly_euclid
a1edce86da9b centos: latest "/ bin / bash" 2 days ago Exited (0) 2 days ago angry_goodall
41035d2328ea centos: latest "/ bin / bash" 3 days ago Exited (0) 3 days ago
14.docker ps command will return some useful information here, including a short container ID: d162d83800cf. Automatically assigned the name: reverent_mclean
15. Note: docker automatically named to the container when the container starts later we can see how we have to specify the name of the vessel.
16. We need to use the command docker logs (container running) in our container.
Let us give the system automatically assigns the name of the vessel using this command.
$ Docker logs angry_goodalldocker logs command which looks like a run in the container and return to the standard output: In this case our command output hello word fantastic; stop the daemon container. To this end let us use docker stop command to stop.
$ Docker stop insane_babbagedocker stop command to stop the container will notify docker running. If it succeeds, it returns the name of the vessel immediately after it stops. By docker ps command to check that it is still working. $ Sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES