[Docker] Docker application scenarios, Docker advantages, Ubuntu Docker installation, using Shell script for installation

Time:2024-3-13
[Docker] Docker application scenarios, Docker advantages, Ubuntu Docker installation, using Shell script for installation

Application Scenarios for Docker

  • Automated packaging and publishing of web applications.
  • Automated testing and continuous integration, releases.
  • Deploy and tune databases or other backend applications in a service-oriented environment.
  • Build your own PaaS environment by compiling from scratch or extending an existing OpenShift or Cloud Foundry platform.

Benefits of Docker

Docker is an open platform for developing, delivering, and running applications.Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With the help of Docker, you can manage your infrastructure in the same way you manage your applications. By utilizing Docker With an approach to rapidly delivering, testing, and deploying code, you can dramatically reduce the delay between writing code and running it in a production environment.
1. Deliver your application quickly and consistently Docker simplifies the development lifecycle by allowing developers to work in a standardized environment using local containers for the applications or services you provide. Containers are well suited to Continuous Integration and Continuous Delivery (CI / CD) workflows, consider the following sample scenarios:
  • Your developers write code locally and share their work with coworkers using Docker containers.
  • They use Docker to push their applications into test environments and perform automated or manual tests.
  • When developers find bugs, they can fix them in the development environment and then redeploy them to the test environment for testing and validation.
  • Once testing is complete, pushing patches to the production environment is as simple as pushing an updated image to the production environment.
2, responsive deployment and expansion Docker is a container-based platform that allows for highly portable workloads.Docker containers can be run locally on a developer’s machine, on a physical or virtual machine in a data center, on a cloud service, or in a hybrid environment. Docker’s portability and lightweight nature also makes it easy for you to fulfill dynamically managed workloads and scale up or down applications and services in real time as directed by business needs. 3. Run more workloads on the same hardware Docker is lightweight and fast. It provides a viable, cost-effective, and efficient alternative to hypervisor-based virtual machines, so you can utilize more computing power to achieve your business goals.Docker is ideal for high-density environments as well as small and medium-sized deployments, and you can do more with less.

Ubuntu Docker installation

Automated installation using the official installation script The installation commands are as follows:
curl -fsSL https://test.docker.com -o test-docker.sh
 sudo sh test-docker.sh
manual installation Uninstall an older version Older versions of Docker are called docker, docker.io or docker-engine. Uninstall them if they are installed:
$ sudo apt-get remove docker docker-engine docker.io containerd runc
currently known asDocker Engine-Community software packagedocker-ce 。 mountingDocker Engine-Community, two ways are described below. Installation using Docker repositories First time installation on a new hostDocker Engine-Community Before that, you need to set up a Docker repository. After that, you can install and update Docker from the repository. Setting up the warehouse Update the apt package index.
$ sudo apt-get update
Install the apt dependency package for fetching the repository over HTTPS:.
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
Add the official GPG key for Docker:
$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 Verify that you now have the key with the fingerprint by searching for the last 8 characters of the fingerprint.
$ sudo apt-key fingerprint 0EBFCD88
   
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <[email protected]>
sub   rsa4096 2017-02-22 [S]
Use the following commands to set up a stable repository
$ sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
  $(lsb_release -cs) \
  stable"
Install Docker Engine-Community Update the apt package index.
$ sudo apt-get update
Install the latest version of Docker Engine-Community and containerd, or go to the next step to install a specific version:
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
To install a specific version of Docker Engine-Community, list the available versions in your repository and select one to install. List the versions available in your repository:
$ apt-cache madison docker-ce

  docker-ce | 5:18.09.1~3-0~ubuntu-xenial | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
  docker-ce | 5:18.09.0~3-0~ubuntu-xenial | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
  docker-ce | 18.06.1~ce~3-0~ubuntu       | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
  docker-ce | 18.06.0~ce~3-0~ubuntu       | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
Install a specific version using the version string in the second column, e.g. 5:18.09.13-0ubuntu-xenial。
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
To test if Docker is installed successfully, enter the following command and the installation is successful if the following message is printed out.
$ sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete                                                                                                                                  Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
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/

Installation using Shell Scripts

Docker provides convenience scripts on get.docker.com and test.docker.com that will quickly install edge and test versions of Docker Engine-Community. The source code for the scripts is in the docker-install repository. These scripts are not recommended for use in production environments and you should be aware of the potential risks before using them:
  • Scripts require running root or having sudo privileges. Therefore, scripts should be carefully checked and reviewed before running them.
  • These scripts try to detect Linux distributions and versions and configure the package management system for you. In addition, the scripts do not allow you to customize any of the installation parameters. This can lead to unsupported configurations from a Docker perspective or from the perspective of your own organization’s guidelines and standards.
  • These scripts will install all the dependencies and recommendations of the package manager without validation. This may install a large number of packages, depending on the current configuration of the host.
  • The script does not provide options for specifying which version of Docker to install, but instead installs the latest version released in the edge channel.
  • Do not use convenience scripts if you have installed Docker on the host using other mechanisms.
This example installs the latest version of Docker Engine-Community on Linux using the script on get.docker.com To install the latest test version, use test.docker.com instead.In each of the following commands, instead of get use test each time it appears.
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
If you want to use Docker as a non-root user, you should consider adding the user to a docker group using something like the following:
$ sudo usermod -aG docker your-user
Uninstalling docker Remove the installation package:
sudo apt-get purge docker-ce
Delete images, containers, configuration files, etc:
sudo rm -rf /var/lib/docker
About [Docker] Docker application scenarios, the advantages of Docker, Ubuntu Docker installation, the use of Shell script for the installation of the details, seven seven will first share here, if you think this article is helpful to you, please give seven seven point a praise, if you find any problem, welcome to leave a message in the comments section!

Recommended Today

STM32 Timer Timing Calculation

STM32 Timer Timing Calculation STM32 Timer Frequency(for) instanceofficialreference STM32 Timer Frequency Timing Time = Timer Frequency / Multiplier / Load Cycle htim1.Init.Prescaler = 72-1; htim1.Init.CounterMode = TIM_COUNTERMODE_UP; htim1.Init.Period = 1*1000*1000; tim = 72×10^6 / (72-1)/ 110001000 = 1us According to the frequency of the timer clock, for example, the frequency of the clock is 72MHZ, […]