Install the docker container tutorial under CentOS7.2

  • 2020-11-03 22:39:52
  • OfStack

Milestone 1:

1. Install dependency packages

[

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

]

2. Install the CentOS7 docker image

[

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

]

3. Install community edition docker

[

yum install docker-ce

]

4. Start the docker container

[

systemctl start docker

]

5. Make docker mirror accelerator

[

cat /etc/docker/daemon.json
{
"registry-mirrors": ["http://b7a9017d.m.daocloud.io"],
"graph": "/opt/mydocker"
}

]

6. Import and make CentOS image (ssh can be connected remotely)

[

docker load < centos7-ssh.tar.gz

]

7. Check that the image import succeeded

[

docker image ls

]

8. Start and create the centoss mirror container (start the first time)

[

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

]

9. View the mirror container and close the container

[

docker container ls
docker stop web03

]

10. Enter the started docker mirror container

[

docker exec -it web03 /bin/bash

]

101. Delete the container you created

[

docker rm -f web03

]

102. ssh connections are allowed, but not directly

[

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

]

103. View IP for the container

[

docker inspect mycentos |grep -i ipaddr

]

Milestone 2: Build a directly connected CentOS container

1. Check the docker network

[

docker network ls

]

2. Open the promiscuous mode of network card

[

ip link set eth0 promisc on

]

3. Create an macvlan network

[

docker network create -d macvlan --subnet 10.0.0.0/24 --gateway 10.0.0.254 -o parent=eth0 mynet

]

4. Specify the network running container

[

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

]

5. Container packaging image (install httpd)

[

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

]

6. Custom mirror running container

[

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

]

Related articles: