------------ ------------ restore content begins
What is the Docker:
docker is an application container engine open source, and is based on the language and follow the people go open source Apache2.0 agreement.
docker container is completely manufactured using a sandbox, there will be no interfaces between them, (similar to the ipone App), more importantly, a very low performance overhead container
docker application scenarios:
Automated packaging and publishing web applications
Automated testing and continuous integration, publishing
Deployment and tuning the database or other back-office applications in a service-oriented environment
Recompile or expand existing Openshift or cloud Foundry PaaS platform to build their own environment
docker advantages:
For the development, delivery and open platform for running applications, docker able to separate applications and infrastructure that can quickly deliver software. With docker can be managed the same way as applications to manage infrastructure. Docker by using the method to quickly deliver, test, and deploy code, you can greatly reduce the delay between writing code and run the code in a production environment
1. Quick and consistently deliver applications
2. Response deployment and expansion
3. run more workloads on the same hardware
docker installation: (Ubuntu lower)
If you have an older version of docker, uninstall and then perform the installation command
Uninstall instructions:
sudo apt-get remove docker docker-engine docker.io containerd runc
1. Replace the domestic software source.
sudo cp /etc/apt/sources.list / etc / apt / sources.list.bak sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list sudo apt update
2. Install the required packages
sudo apt install apt-transport-https ca-certificates software-properties-common curl
3. Add the GPG key and add Docker-ce source software, or to Docker-ce source Chinese University of Science and Technology as an Example
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \ $(lsb_release -cs) stable"
4. Add the package cache updated successfully
sudo apt update
5. Installation Docker-ce
sudo apt install docker-ce
6. Set the boot from the start and start Docker (set by default after successful installation and start can be ignored)
sudo systemctl enable docker
sudo systemctl start docker
7. Test Run
sudo docker run hello-world
8. Add Docker current user to the user group, can not run sudo Docker (optional)
sudo groupadd docker
sudo usermod -aG docker $USER
9. Add User Group Test
docker run hello-world
Docker use:
1. Run the program in the container, such as the use of docker run command to run an application within the container
docker run ubuntu:15.10 /bin/echo "hello world" hello world Parameters Resolution: 1 docker:. Docker's binaries 2 RUN:. In front of the docker to run in combination with a container 3. ubuntu15.10 designated to run a mirror, Docker first looks for the existence of a mirror from the local host, and if not, Docker on public downloaded from a mirror image warehouse Docker Hub. (That is, you install ubuntu version number) 4. / bin / echo " the Hello world " : command in the container start in The above command can be interpreted as meaning a complete: DOcker ubuntu15.10 to create a new image container, the container then performed bin / echo " Hello World " , and then outputs the execution result
2. Run interactive container
By two parameters -i -t docker, so the ability to run container docker "dialogue" to achieve
docker run -i -t ubuntu:15.10 /bin/bash Parameter analysis - T: new container in the specified pseudo-terminal or a terminal. - i: allows you to enter criteria for a container (STDIN) proceeds interaction After execution, it will enter into a ubuntu15. Container system 10
3. Review the list of files in the current directory and version information
(Mode in the container) View the version number: CAT / proc / Versio View a list of files in the current directory: ls
4. Exit container
Use exit, or ctrl + D
5. Start the container (background mode)
Create a process to run container
(Ubuntu Terminal) docker run -d ubuntu:18.04 /bin/sh -c "while true; do echo hello world; sleep 1; done" In the output, and it will not be expected "hello world" but a long string of characters This string is called a long string container ID, for each container are unique, we can see what happened the corresponding container by container ID First, we need to make sure the container has run, you can be viewed by docker ps docker ps Output: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 39771f265f7f ubuntu:18.04 "/bin/sh -c 'while t..." 7 minutes ago Up 7 minutes unruffled_swirles
Output More:
CONTAINER ID: ID of the container
IMAGE: the mirror used
COMMAND: command to run at startup container
CREATED: Time to create container
STATUS: container status
There are seven states:
created: has been created
restaring: Rebooting
running: running
removing: Migration
paused: Pause
exited: Stop
dead: Death
PORTS: Port information containers
End ------------ ------------ restore content