Install Centos7 operating system in Docker

Install Centos7 operating system in Docker#

If you have not installed Docker, please move to:

Centos7.x install Docker

My server version#

[ root@shendu ~]# docker version
Client:
 Version:1.13.1
 API version:1.26
 Package version: docker-1.13.1-102.git7f2769b.el7.centos.x86_64
 Go version:      go1.10.3
 Git commit:      7f2769b/1.13.1
 Built:           Mon Aug  515:09:422019
 OS/Arch:         linux/amd64

Server:
 Version:1.13.1
 API version:1.26(minimum version 1.12)
 Package version: docker-1.13.1-102.git7f2769b.el7.centos.x86_64
 Go version:      go1.10.3
 Git commit:      7f2769b/1.13.1
 Built:           Mon Aug  515:09:422019
 OS/Arch:         linux/amd64
 Experimental:false[root@shendu ~]# 

[ root@shendu ~]# uname -a
Linux shendu 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 1222:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[ root@shendu ~]# 

[ root@shendu ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810(Core)[root@shendu ~]# 

Description:

In view of the domestic network problems, it is very slow to pull the Docker image, and it needs to be set to a domestic image before installation, which can be accelerated.

One, set up mirror accelerator#

I am using NetEase’s mirror address: http://hub-mirror.c.163.com

NetEase Cloud Mirror official address https://c.163yun.com/hub#/library/repository/info?repoId=1055

[ root@shendu ~]# 
[ root@shendu ~]# cat /etc/docker/daemon.json 
{" registry-mirrors":["http://hub-mirror.c.163.com"]}[root@shendu ~]#
sudo systemctl daemon-reload 
 
sudo systemctl restart docker
FROM hub.c.163.com/netease_comb/centos:7
MAINTAINER netease
 
# Update yum source
RUN yum makecache fast && yum -y update glibc    
 
# Install common software
RUN yum install -y openssh-server vim tar wget curl rsync bzip2 iptables tcpdump less telnet net-tools lsof
# Initialize ssh login
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
RUN ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
RUN ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ''
RUN echo "RSAAuthentication yes">>/etc/ssh/sshd_config
RUN echo "PubkeyAuthentication yes">>/etc/ssh/sshd_config    
 
RUN yum clean all
 
# Start the sshd service and expose port 22
RUN mkdir /var/run/sshd    
 
EXPOSE 22    
 
CMD ["/usr/sbin/sshd","-D"]

Two, get Centos7 mirror#

Three, start the container#

Fourth, open the ssh link#

1、 Enter the os1 container:

Command: docker exec -it os1 bash

[ root@shendu ~]# 
[ root@shendu ~]# docker exec -it os1 bash
[ root@d6898c947c4b /]# 
[ root@d6898c947c4b /]# 

2、 Start ssh:

[ root@d6898c947c4b /]# /usr/sbin/sshd -D

[ root@d6898c947c4b /]# /usr/sbin/sshd -D &

3、 Check if it has started successfully

Use the command: netstat -ntpl |grep 22 or lsof -i:22

[ root@d6898c947c4b /]# 
[ root@d6898c947c4b /]# netstat -ntpl |grep 22
tcp        000.0.0.0:220.0.0.0:*               LISTEN      44/sshd             
tcp6       00:::22:::*                    LISTEN      44/sshd             
[ root@d6898c947c4b /]# 
[ root@d6898c947c4b /]#        
[ root@d6898c947c4b /]# lsof -i:22
COMMAND PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
sshd     44 root    3u  IPv4 32153435      0t0  TCP *:ssh(LISTEN)
sshd     44 root    4u  IPv6 32153437      0t0  TCP *:ssh(LISTEN)[root@d6898c947c4b /]# 
[ root@d6898c947c4b /]# 
[ root@d6898c947c4b /]# 

If the above results appear, it is considered a success.

Five, modify the root password#

[ root@d6898c947c4b /]# 
[ root@d6898c947c4b /]# passwd root
Changing password for user root.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype newpassword: 
passwd: all authentication tokens updated successfully.[root@d6898c947c4b /]# 

Six, perform ssh remote login test#

Recommended Posts

Install Centos7 operating system in Docker
Install docker on Centos system
CentOS 7 install Docker
CentOS7 install Docker
Install MySql with Docker in CentOS7
Centos7 install Docker
Centos7 install docker18
centos7 install docker
CentOS 6 install Docker
Centos8 install Docker
Graphic KVM to install CentOS7.6 operating system
Install Docker CE in yum under CentOS 7
Install Docker on Centos7
Install MySQL5.7 in centos7
Install php in centos
CentOS 7 install Docker service
VirtualBox install CentOS system
install Docker on centos6.5
CentOS 7 install Docker CE
CentOS install nginx+tomcat+java+mysql operating environment
Install docker transfer on Centos7
Install JDK8 in rpm on CentOS7
Minimal install JDK 1.8 tutorial in CentOS 7
How to install Centos operating system on VMware virtual machine
Install Percona Server database (in CentOS 8)
Install and configure Docker in Ubuntu
Install java in yum mode in Centos
Container study notes CentOS7 install Docker
CentOS7.2 install lepus database monitoring system
Install and use docker under CentOS 6.8
How to install HDP2.6 in Centos7.2
001. Installation of enterprise-level CentOS7.6 operating system
1.5 Install Centos7
Install and configure FreeIPA in Centos7
How to install Android SDK in centos7
Centos7.6 operating system installation and optimization record
Install mysql8.0.13 version under Linux CentOS7 system
CentOS container installation in Docker uses MySQL
Deploy Docker and configure Nginx in CentOS
Install CentOS7 virtual machine, configure docker suite
Compile and install nodejs and yum in Centos8
Linux install Docker and run Ubuntu system
CentOS7 system yum way to install MySQL5.7
Centos7.3 install nginx
CentOS7.2 install Mysql5.7.13
CentOS install Redmine
CentOS7 install MySQL
Centos7 install protobuf
CentOS7 install GlusterFS
ubuntu18.04 install docker
CentOS 7.4 install Zabbix 3.4
Centos6.5 install Tomcat
Vmware install CentOS6
CentOS 7 install Hadoop 3.0.0
Centos7 install Python2.7
Centos 7.6 install seleniu
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
centos system management
CentOS install mysql
CentOS install openjdk 1.8