HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
docker client is very simple, we can directly enter docker command to see all the command options Docker client.
w3resource@w3resource:~# docker
Docker command --help command through a deeper understanding of the specified command Docker use.
For example, we want to see specific instructions for use docker stats:
w3resource@w3resource:~# docker stats --help
We run the front of the container and not some of what particular use.
Let's try to use docker to build a web application.
We will run a Python Flask docker container application to run a web application.
w3resource@w3resource:~# docker run -d -P training/webapp python app.py
Parameter Description:
-d: the container to run in the background.
-P: Internal network used by the container port mapping to the host we use.
Use docker ps to view the vessel we are running
w3resource@w3resource:~$ docker ps
Here more information about the ports.
PORTS 0.0.0.0:32769->5000/tcp
Docker open port 5000 (default Python Flask port) is mapped to the host port 32769.
Then we can access the application through a browser WEB
We can also specify the -p flag to bind the specified port.
w3resource@w3resource:~$ docker run -d -p 5000:5000 training/webapp python app.py
docker ps See vessel running
Port 5000 is mapped to the interior of the container port 5000 on our local host.
By docker ps command to view port mapping container, docker also provides another shortcut: docker port, use docker port can view the specified (ID or name) of a container port mapping to determine the host port number.
The above web application we created for the container ID: 7a38a1ad55c6 named: determined_swanson
Can I use docker port 7a38a1ad55c6 or docker port determined_swanson to view the mapping for the container port
w3resource@w3resource:~$ docker port 7a38a1ad55c6 5000/tcp -> 0.0.0.0:5000
w3resource@w3resource:~$ docker port determined_swanson 5000/tcp -> 0.0.0.0:5000
docker logs [ID or name] can see the standard output inside the container.
w3resource@w3resource:~$ docker logs -f 7a38a1ad55c6 * Running on ht tp:// 0.0.0.0 : 5000 / (Press CTRL+C to quit) 192.168.239.1 - - [09/May/2016 16:30:37] "GET / HTTP/1.1" 200 - 192.168.239.1 - - [09/May/2016 16:30:37] "GET /favicon.ico HTTP/1.1" 404 -
-f: Let dokcer logs the same as using the tail -f to standard output inside the container.
From the above, we can see the application using port 5000 to be able to view and access log application.
We can also use docker top to view the interior of the container running processes
w3resource@w3resource:~$ docker top determined_swanson
Use docker inspect to see the underlying information Docker's. It will return a JSON file records the configuration and status information Docker container.
w3resource@w3resource:~$ docker inspect determined_swanson [ { "Id": "7a38a1ad55c6914b360b565819604733db751d86afd2575236a70a2519527361", "Created": "2016-05-09T16:20:45.427996598Z", "Path": "python", "Args": [ "app.py" ], "State": { "Status": "running", /en/en/en
w3resource@w3resource:~$ docker stop determined_swanson determined_swanson
The vessel has stopped, we can use the command docker start to start.
w3resource@w3resource:~$ docker start determined_swanson determined_swanson
docker ps -l to see the vessel running
Container is running, we can use docker restart command to restart
We can use docker rm command to delete unnecessary container
w3resource@w3resource:~$ docker rm determined_swanson determined_swanson
When you delete a container, the container must be stopped, otherwise they will be reported the following error
w3resource@w3resource:~$ docker rm determined_swanson Error response from daemon: You cannot remove a running container 7a38a1ad55c6914b360b565819604733db751d86afd2575236a70a2519527361. Stop the container before attempting removal or use -f