docker設定centos容器支援

2021-08-06 03:11:16 字數 1094 閱讀 5068

1. 啟動docker:service docker start

2. 拉取centos映象: docker pull centos

3. 啟動centos映象: docker run -itd /bin/bash

4. 進入容器: docker attach

5. 安裝ifconfig : yum search ifconfig 

yum install net-tools.x86_64

6. 安裝ssh: yum install -y openssh-server

7. 編輯sshd的配置檔案/etc/ssh/sshd_config,將其中us人pam引數設定為no

8. 設定容器root密碼 echo "root:123456"|chpasswd

9. 在宿主機中生成金鑰對,把生成的公鑰檔案內容複製到容器的/root/.ssh/authorized_keys,

ssh-keygen -t rsa直接回車即可,

檢視公鑰內容 cat /root/.ssh/id_rsa.pub

10. 在容器中/usr/sbin/sshd -d

如果報could not load host key: /etc/ssh/ssh_ed25519_key

could not load host key: /etc/ssh/ssh_rsa_key

could not load host key: /etc/ssh/ssh_dsa_key

分別執行  ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key

ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key

ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key

然後退出容易:exit

11.生成支援ssh的新centos映象

docker commit sshd-centos

12.docker run -p 10022:22 -d sshd-centos /usr/sbin/sshd -d

13.windows下利用ssh工具訪問宿主機的ip埠就可以訪問到容器了

docker設定mysql redis等容器的時區

問題 現在本地docker的mysql容器時區不對,需要為中國的時區 解決 檢視所有容器 docker ps a 進入mysql容器 docker exec if 容器id bin bash 檢視當前時間 date r 進入 usr share zoneinfo asia目錄 cd usr shar...

CentOS 7 x 系統上安裝 Docker容器

備註 docker io 是 centos 6 的情況,在 centos 7 上,docker 已經正式收錄到 centos extras 庫內,名字已經是 docker 了2.配置網路yum源 需要保證外網開通 cd etc yum.repos.d wget 3.1.清除以前使用yum的快取 yu...

Docker安裝及啟動乙個CentOS容器

192.168.1.137 docker pull centos 7 docker run itd name centos7 imageid bin bash 進入centos容器 docker exec it centos7 bin bash 沒有ifconfig ssh vim tree wge...