Environment: ubuntu16.04, install the latest version of Docker
1. Add GPG
Key :
sudo apt-key adv--keyserver hkp://p80.pool.sks-keyservers.net:80-- recv-keys58118e89f3a912897c070adbf76221572c52609d
2. Add Source
new file: /etc/apt/sources.list.d/docker.list
,
Add content inside:
Debhttps://apt.dockerproject.org/repo Ubuntu-xenial Main
3. Update Source
sudo apt update
4. installation
sudo apt-getinstall docker-engine
5. start Docker and set Docker as the boot entry.
sudo service Dockerstart
Chkconfig Docker on
6. using the modern SYSTEMD syntax, start Docker and set it as the boot entry, as follows:
Systemctl Start Docker.service
Systemctl Enable Docker.service
7. Docker Common Commands
1) sudo docker info View Daoker program information and whether it works
2) sudo docker run-i-t Ubuntu/bin/bash runs a docker container, the-I flag guarantees that the STDIN in the container is on, and-t means it is turned on as a terminal, and these two parameters License to run the container is an interactive one.
Ubuntu represents a running image,/bin/bash represents a running program
3) Docker PS sees only the containers that are running. -a means show all,-l displays the last container, including the one that is running and stopped.
4) sudo docker run--name cxx-i-tubuntu/bin/bash
Represents the creation of a container with a container name of cxx. --name specifying the container name
Docker RM Remove container-f Force Delete to delete a running container
Docker RMI Mirror name/id means delete mirror
sudo docker start ID / name start a container that has stopped
sudo docker attach ID / The name is re-attached to the container's session, provided that the stopped container is started
Docker Run the command uses the-d parameter, so Docker puts the container in the background to run
Called a daemon container.
sudo docker logs container name/id the docker logs command to get the container's logs for the daemon container running in the background. You can use the-f parameter after the command to monitor the log for Docker, which is very similar to the TAIL-F command. CTRL + Stop
sudo docker top container name/id View all processes running within the container, the user and ID of the running process
A new process is started inside the container with the Docker EXEC command. There are two types of processes that you can run within a container: background tasks and interactive tasks. The background task runs inside the container without interaction requirements, while the interactive task remains in the foreground.
Port mappings
- P Host Port: Container port
- P the uppercase P does not add the port number to indicate a random mapping.
- P IP: Host Port: Container port, which represents the mapping of the specified host IP and host port to the container port.
8. Docker Data Management for containers
Data volumes
run–it-v/date--name test1 ubuntu/bin/bash Indicates that the host directory is mounted on a container, and if there is no/date in the host, the directory is created and the host and container are sharing data in that directory.
run–it–v src:dst--name test2 ubuntu/bin/bash A specified directory in a container that can mount a directory that already exists in the host.
- v Src:dst:ro plus RO indicates that the container is mounted in a directory that is read-only.
Data Volume container
Run–it--nametest3–volumes-from test1 Ubuntu/bin/bash
Share Test1 mounted/date data volumes with TEST3, and test1 can be started or not.
This article is from the "11859529" blog, please be sure to keep this source http://11869529.blog.51cto.com/11859529/1882039
ubuntu16.04, install the latest version of Docker