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

Tutorial on installing docker Container under CentOS7.2

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

Share

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

First milestone:

one。 Install dependency packages

Yum install-y yum-utils device-mapper-persistent-data lvm2

two。 Install the CentOS7 docker image

Yum-config-manager-- add-repo https://download.docker.com/linux/centos/docker-ce.repo

three。 Install community version of docker

Yum install docker-ce

four。 Start the docker container

Systemctl start docker

five。 Making docker Image Accelerator

Cat / etc/docker/daemon.json

{

"registry-mirrors": ["http://b7a9017d.m.daocloud.io"],"

"graph": "/ opt/mydocker"

}

six。 Import and make CentOS image (can be connected remotely by ssh)

Docker load < centos7-ssh.tar.gz

seven。 Check that the image was imported successfully

Docker image ls

eight。 Start and create the centoss image container (first startup)

Docker run-dit-- name web03 centos7-ssh:latest / bin/bash

nine。 View the mirror container and close the container

Docker container ls

Docker stop web03

ten。 Enter the started docker image container

Docker exec-it web03 / bin/bash

eleven。 Delete the created container

Docker rm-f web03

twelve。 Allow ssh connections, but not directly

Docker run-d-privileged-name mycentos-h web centos7-ssh:latest / usr/sbin/init

thirteen。 View the IP of the container

Docker inspect mycentos | grep-I ipaddr

Second milestone: building a directly connectable CentOS container

one。 View the docker network

Docker network ls

two。 Turn on the hybrid mode of the network card

Ip link set eth0 promisc on

three。 Create a macvlan network

Docker network create-d macvlan-- subnet 10.0.0.0According 24-- gateway 10.0.254-o parent=eth0 mynet

four。 Specify the network operation container

Docker run-d-privileged-network mynet-ip 10.0.0.110-name oldboy43-h oldboy43 centos7-ssh:latest / usr/sbin/init

five。 Container packaging image (install httpd)

Docker commit-m "my mariadb" oldboy43 my_mariadb:v1

six。 Custom image running container

Docker run-d-privileged-network mynet-ip 10.0.0.112-name mydb-h db05 my_mariadb:v1 / usr/sbin/init

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