Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Docker under Centos

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Docker under Centos

Install Docker using a script

1. Log in to Centos with sudo or root permissions.

2. Make sure the yum package is up to date.

$sudo yum update

3. Execute Docker installation script.

$curl-fsSL https://get.docker.com/ | sh

Executing this script adds the docker.repo source and installs Docker.

4. Start Docker process.

$sudo service docker start

5. Verify that docker is installed successfully and execute a test image in the container.

$sudo docker run hello-world

At this point, the installation of docker on the CentOS system is complete.

Install Docker using yum (recommended)

Before you install Docker CE on a new host for the first time, you need to set up the Docker repository. You can then install and update Docker from the repository.

Set up the repository

1. Install the required packages. Yum-utils provides yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by devicemapper storage drivers.

$sudo yum install-y yum-utils\

Device-mapper-persistent-data\

Lvm2

2. Use the following command to set up the stable repository. Even if you still want to install the build from the edge or test repository, you always need a stable repository.

$sudo yum-config-manager\

-- add-repo\

Https://download.docker.com/linux/centos/docker-ce.repo

Optional: enable edges and test repositories. These repositories are included in the files above docker.repo, but are disabled by default. You can enable them with the stable repository. (docker stable stable is used by default if it is not enabled)

$sudo yum-config-manager-enable docker-ce-edge

$sudo yum-config-manager-enable docker-ce-test

You can disable the edge or test the repository by running a command with a flag. To re-enable it, use this flag. The following command disables the edge repository. Yum-config-manager--disable--enable

$sudo yum-config-manager-disable docker-ce-edge

Note: starting with Docker 17.06, the stable version will also be pushed to the edge and the repository will be tested.

Learn about stability and edge building.

Install DOCKER CE

4. Install the latest version of Docker CE, or go to the next step to install a specific version:

$sudo yum install docker-ce

If prompted to accept the GPG key, verify that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it.

How many Docker repositories are there?

If you have multiple Docker repositories enabled, installing or updating without specifying a version in the yum install or yum update command will always install the highest possible version, which may not suit your stability needs.

Docker is installed but not started. The docker group was created, but no users were added to the group.

5. To install a specific version of Docker CE, list the available versions in repo, and then select and install:

One. List and sort the versions available in your warehouse. This example sorts the results by version number, from highest to lowest, and is truncated:

$yum list docker-ce-- showduplicates | sort-r

Docker-ce.x86_64 18.09.0.ce-1.el7.centos docker-ce-stable

The list returned depends on the enabled repository and is specific to your version of CentOS (.el7 is represented by a suffix in this example).

Install a specific version with its fully qualified package name, the package name (docker-ce) plus the version string (column 2) up to the first hyphen-for example, docker-ce-18.03.0.ce separated by a hyphen ().

$sudo yum install docker-ce-

Docker is installed but not started. The docker group was created, but no users were added to the group.

6. Start Docker.

$sudo systemctl start docker

7. Docker verifies that it is installed correctly by running the hello-world image.

$sudo docker run hello-world

This command downloads the test image and runs it in the container. When the container runs, it prints an informational message and exits.

Docker CE is installed and running. You need to use it sudo to run the Docker command. Continue Linux postinstall to allow non-privileged users to run Docker commands and other optional configuration steps.

Upgrade DOCKER CE

To upgrade Docker CE, follow the installation instructions to select the new version to install.

The use of Docker

Docker run ubuntu:15.10 / bin/echo "Hello world"-- docker [option] OS / bash//echo "content"

Each parameter is resolved:

Docker: the binary execution file for Docker.

Run: combined with the previous docker to run a container.

Ubuntu:15.10 specifies the image to run. Docker first looks up whether the image exists on the local host. If it does not exist, Docker downloads the public image from the image repository Docker Hub.

/ bin/echo "Hello world": commands executed in the startup container

The complete meaning of the above command can be interpreted as: Docker creates a new container in the ubuntu15.10 image, then executes bin/echo "Hello world" in the container, and then outputs the result.

[option] run, stop

1. Docker-h help

2. Obtain the image

Sudo docker pull NAME [: TAG]

Sudo docker pull centos:latest

3. Start the Container box

Sudo docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Sudo docker run-t-I contos / bin/bash

4. View the list of images and list all the local images

Sudo docker images [OPTIONS] [NAME]

Sudo docker images centos

5. Check the container list to see all the container we have created.

Sudo docker ps [OPTIONS]

Sudo docker ps-a

6. Delete the image and delete a downloaded image locally

Sudo docker rmi IMAGE [IMAGE...]

Sudo docker rmi centos:latest

7. Remove one or more container instances

Sudo docker rm [OPTIONS] CONTAINER [CONTAINER...]

Remove all micro-running containers

Sudo docker rm sudo docker ps-aq

8. Stop a running container

Sudo docker kill [OPTIONS] CONTAINER [CONTAINNER...]

Sudo docker kill 026e

Or docker stop CONTAINER.

9. Restart a running container

Sudo docker restart [OPTIONS] contains [CONTAINER]

Sudo docker restart 026e

10. Start a stopped container

Sudo docker start [OPTIONS] CONTAINER [CONTAINER..]

Sudo docker start 026e

11. Modify the storage path of docker

Vim / usr/lib/systemed/system/docker.server

Add-- graph / path after unix:// to restart or start docker

* to delete an Docker image, you need to stop the container where the image is enabled and delete it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report