Datawhale & Docker (Docker introduction and installation)
Learning Outline:
Open source content:
catalogue
Datawhale & Docker (introduction and installation of Docker)
1. Problems to be solved through learning
2. Some thoughts before learning
3. What other advantages does docker have
3. Some problems encountered during installation
1, Docker introduction
1. Problems to be solved through learning
Through the study of docker's introduction, we intend to solve two problems:
- What is Docker
- Why use Docker
2. Some thoughts before learning
Through the previous study and communication and discussion with you, I learned that docker is more of a container technology, but after systematic learning, I have a new understanding of docker.
- Docker further encapsulates the container, from file system, network interconnection to process isolation, which greatly simplifies the creation and maintenance of the container. It makes docker technology lighter and faster than virtual machine technology.
- Docker # is lighter than traditional virtual machines, as shown in the figure below
And compare traditional virtual machines:
characteristic | container | virtual machine |
---|---|---|
start-up | Second order | Minute level |
Hard disk usage | Typically , MB | Generally , GB |
performance | Near primary | weaker than |
System support | A single machine supports thousands of containers | Generally dozens |
3. What other advantages does docker have
Docker also has many advantages:
- More efficient use of system resources: Docker # has higher utilization of system resources because the container does not need additional overhead such as hardware virtualization and running a complete operating system.
- Faster start-up time: Docker container applications run directly in the host kernel without starting a complete operating system, so they can achieve a start-up time of seconds or even milliseconds.
- Consistent running environment: the image of Docker # provides a complete running environment other than the kernel to ensure the consistency of the application running environment.
- Continuous delivery and deployment: Docker # can realize continuous integration, continuous delivery and deployment by customizing application images.
- Easier migration: Docker # ensures the consistency of the execution environment and makes the migration of applications easier.
- Easier maintenance and expansion: the layered storage and image technology used by Docker # makes it easier to reuse the repeated parts of the application, and also makes it easier to maintain and update the application. It is also very simple to further expand the image based on the basic image.
2, Docker installation
1. Installation introduction
Docker can be installed on Linux, Windows 10, Mac OS and other OS. I use Ubuntu system here, so I only demonstrate the installation steps of Ubuntu system.
According to the operating instructions: first, prepare the Linux operating environment and Ubuntu operating system.
be careful:
Docker can be installed on 64 bit x86 platform or ARM platform. In the Ubuntu distribution, the long-term supported version of lts (long term support) will receive 5 years of upgrade and maintenance support. This version will be more stable. Therefore, it is recommended to use the LTS version in the production environment
2. Installation steps:
First, select APT installation: you need to add the software package transmitted using HTTPS and CA certificate
$ sudo apt-get update $ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg \ lsb-release
Then you need to add the GPG key
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Report to # sources Add Docker software source to the list
$ echo \ "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Note: This version is a stable APT image source. If you need a beta version, please change stable to test.
Update apt package cache and install {docker CE
$ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io
You can use this script to install on Ubuntu system. In addition, you can use domestic source to install through -- mirror option:
# $ curl -fsSL test.docker.com -o get-docker.sh $ curl -fsSL get.docker.com -o get-docker.sh $ sudo sh get-docker.sh --mirror Aliyun # $ sudo sh get-docker.sh --mirror AzureChinaCloud
After executing this command, the script will automatically make all preparations and install the stable version of Docker in the system.
Note: for the beta version, please visit test docker. Com get script
Start Docker
$ sudo systemctl enable docker $ sudo systemctl start docker
Add users who need to use # docker # to the # docker # user group.
$ sudo groupadd docker
Add the current user to the docker group:
$ sudo usermod -aG docker $USER
Close the current terminal, reopen it, and enter the command to check whether it is correct.
$ docker run --rm hello-world
If the following information appears, the installation has been successful.
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world b8dfde127a29: Pull complete Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
The of Ubuntu system should be displayed as follows:
3. Some problems encountered during installation
Ubuntu starts Docker "Got permission denied while trying to connect to the Docker daemon socket“
Reason: the docker process uses Unix socket instead of TCP port. By default, Unix socket belongs to the root user, so it needs {root permission} to access
terms of settlement:
sudo gpasswd -a $XHC docker #Check whether the current user is already in the docker user group sudo gpasswd -a $USER docker #Add current user to docker user group newgrp docker #Update docker user group
By executing the "docker version" command, you can find that the operation is successful and no error is reported.
Summary:
Through the introduction and study of docker, we have a new understanding of docker, which is no longer limited to the previous single way of understanding, and deepened professional ideas. Through the actual operation, the installation of docker on Ubuntu system has encountered some small problems, but it has been perfectly realized by looking up materials. I hope that I will continue to refuel, fight side by side with you, and carefully learn the basic knowledge of docker. Success is stupid persistence.