37.1准备工作
setenforce 0 vim /etc/selinux/config SELINUX=disabled
37.2 创建docker centos-ssh-root
37.2.1 创建dockerfile
# 选择一个已有的os镜像作为基础 FROM centos # 镜像的作者 MAINTAINER baoyou curiousby@163.com # 安装openssh-server和sudo软件包,并且将sshd的UsePAM参数设置成no RUN yum install -y openssh-server sudo RUN sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config #安装openssh-clients RUN yum install -y openssh-clients # 添加测试用户root,密码root,并且将此用户添加到sudoers里 RUN echo "root:root" | chpasswd RUN echo "root ALL=(ALL) ALL" >> /etc/sudoers # 下面这两句比较特殊,在centos6上必须要有,否则创建出来的容器sshd不能登录 RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key # 启动sshd服务并且暴露22端口 RUN mkdir /var/run/sshd EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"]
37.2.2 执行命令
mkdir centos-ssh-root cd centos-ssh-root vim Dockerfile docker build -t "curiousby/centos-ssh-root:original" .
37.2.3 build 运行日志
[root@bogon centos-ssh-root]# docker build -t curiousby/centos-ssh-root:original . Sending build context to Docker daemon 2.56kB Step 1/12 : FROM centos ---> 328edcd84f1b Step 2/12 : MAINTAINER curiousby curiousby@163.com ---> Running in a07c67ece348 ---> a3f6c43634d0 Removing intermediate container a07c67ece348 Step 3/12 : RUN yum install -y openssh-server sudo ---> Running in 7319491e2cb1 Loaded plugins: fastestmirror, ovl http://centos.ustc.edu.cn/centos/7.3.1611/updates/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2001:da8:d800:95::110: Network is unreachable" Trying other mirror. Determining fastest mirrors * base: mirrors.btte.net * extras: mirrors.nwsuaf.edu.cn * updates: mirrors.nwsuaf.edu.cn Resolving Dependencies --> Running transaction check ---> Package openssh-server.x86_64 0:6.6.1p1-35.el7_3 will be installed --> Processing Dependency: openssh = 6.6.1p1-35.el7_3 for package: openssh-server-6.6.1p1-35.el7_3.x86_64 --> Processing Dependency: fipscheck-lib(x86-64) >= 1.3.0 for package: openssh-server-6.6.1p1-35.el7_3.x86_64 --> Processing Dependency: libwrap.so.0()(64bit) for package: openssh-server-6.6.1p1-35.el7_3.x86_64 --> Processing Dependency: libfipscheck.so.1()(64bit) for package: openssh-server-6.6.1p1-35.el7_3.x86_64 ---> Package sudo.x86_64 0:1.8.6p7-23.el7_3 will be installed --> Running transaction check ---> Package fipscheck-lib.x86_64 0:1.4.1-5.el7 will be installed --> Processing Dependency: /usr/bin/fipscheck for package: fipscheck-lib-1.4.1-5.el7.x86_64 ---> Package openssh.x86_64 0:6.6.1p1-35.el7_3 will be installed ---> Package tcp_wrappers-libs.x86_64 0:7.6-77.el7 will be installed --> Running transaction check ---> Package fipscheck.x86_64 0:1.4.1-5.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: openssh-server x86_64 6.6.1p1-35.el7_3 updates 440 k sudo x86_64 1.8.6p7-23.el7_3 updates 735 k Installing for dependencies: fipscheck x86_64 1.4.1-5.el7 base 21 k fipscheck-lib x86_64 1.4.1-5.el7 base 11 k openssh x86_64 6.6.1p1-35.el7_3 updates 438 k tcp_wrappers-libs x86_64 7.6-77.el7 base 66 k Transaction Summary ================================================================================ Install 2 Packages (+4 Dependent packages) Total download size: 1.7 M Installed size: 4.9 M Downloading packages: Public key for fipscheck-1.4.1-5.el7.x86_64.rpm is not installed warning: /var/cache/yum/x86_64/7/base/packages/fipscheck-1.4.1-5.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Public key for sudo-1.8.6p7-23.el7_3.x86_64.rpm is not installed http://mirrors.nwsuaf.edu.cn/centos/7.3.1611/updates/x86_64/Packages/openssh-6.6.1p1-35.el7_3.x86_64.rpm: [Errno 12] Timeout on http://mirrors.nwsuaf.edu.cn/centos/7.3.1611/updates/x86_64/Packages/openssh-6.6.1p1-35.el7_3.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds') Trying other mirror. -------------------------------------------------------------------------------- Total 32 kB/s | 1.7 MB 00:52 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-3.1611.el7.centos.x86_64 (@CentOS) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : fipscheck-1.4.1-5.el7.x86_64 1/6 Installing : fipscheck-lib-1.4.1-5.el7.x86_64 2/6 Installing : openssh-6.6.1p1-35.el7_3.x86_64 3/6 Installing : tcp_wrappers-libs-7.6-77.el7.x86_64 4/6 Installing : openssh-server-6.6.1p1-35.el7_3.x86_64 5/6 Installing : sudo-1.8.6p7-23.el7_3.x86_64 6/6 Verifying : openssh-6.6.1p1-35.el7_3.x86_64 1/6 Verifying : openssh-server-6.6.1p1-35.el7_3.x86_64 2/6 Verifying : sudo-1.8.6p7-23.el7_3.x86_64 3/6 Verifying : tcp_wrappers-libs-7.6-77.el7.x86_64 4/6 Verifying : fipscheck-lib-1.4.1-5.el7.x86_64 5/6 Verifying : fipscheck-1.4.1-5.el7.x86_64 6/6 Installed: openssh-server.x86_64 0:6.6.1p1-35.el7_3 sudo.x86_64 0:1.8.6p7-23.el7_3 Dependency Installed: fipscheck.x86_64 0:1.4.1-5.el7 fipscheck-lib.x86_64 0:1.4.1-5.el7 openssh.x86_64 0:6.6.1p1-35.el7_3 tcp_wrappers-libs.x86_64 0:7.6-77.el7 Complete! ---> a5b6b2590449 Removing intermediate container 7319491e2cb1 Step 4/12 : RUN sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config ---> Running in cd9fa1a6f379 ---> b3ad6bbf3c1b Removing intermediate container cd9fa1a6f379 Step 5/12 : RUN yum install -y openssh-clients ---> Running in fadadcf8ab9b Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.nwsuaf.edu.cn * updates: mirrors.nwsuaf.edu.cn Resolving Dependencies --> Running transaction check ---> Package openssh-clients.x86_64 0:6.6.1p1-35.el7_3 will be installed --> Processing Dependency: libedit.so.0()(64bit) for package: openssh-clients-6.6.1p1-35.el7_3.x86_64 --> Running transaction check ---> Package libedit.x86_64 0:3.0-12.20121213cvs.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: openssh-clients x86_64 6.6.1p1-35.el7_3 updates 642 k Installing for dependencies: libedit x86_64 3.0-12.20121213cvs.el7 base 92 k Transaction Summary ================================================================================ Install 1 Package (+1 Dependent package) Total download size: 735 k Installed size: 2.4 M Downloading packages: -------------------------------------------------------------------------------- Total 111 kB/s | 735 kB 00:06 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libedit-3.0-12.20121213cvs.el7.x86_64 1/2 Installing : openssh-clients-6.6.1p1-35.el7_3.x86_64 2/2 Verifying : openssh-clients-6.6.1p1-35.el7_3.x86_64 1/2 Verifying : libedit-3.0-12.20121213cvs.el7.x86_64 2/2 Installed: openssh-clients.x86_64 0:6.6.1p1-35.el7_3 Dependency Installed: libedit.x86_64 0:3.0-12.20121213cvs.el7 Complete! ---> 7c2753e2677d Removing intermediate container fadadcf8ab9b Step 6/12 : RUN echo "root:root" | chpasswd ---> Running in 75fab0b6b241 ---> c1cb3babeee2 Removing intermediate container 75fab0b6b241 Step 7/12 : RUN echo "root ALL=(ALL) ALL" >> /etc/sudoers ---> Running in f0c0c32b70c1 ---> 48f3a187f13f Removing intermediate container f0c0c32b70c1 Step 8/12 : RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key ---> Running in afc9cf2b6d76 Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: 13:ce:12:9b:d1:4f:5e:ee:35:b1:ed:48:60:58:92:35 root@c7947be2eb9d The key's randomart image is: +--[ DSA 1024]----+ | .oE | | . .+ . | | o o o + . | | B = + . + | | + S o . = .| | . . . o + | | . . .| | | | | +-----------------+ Enter passphrase (empty for no passphrase): Enter same passphrase again: ---> 8d9c838f0e26 Removing intermediate container afc9cf2b6d76 Step 9/12 : RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key ---> Running in d7131a2534c2 Generating public/private rsa key pair. Your identification has been saved in /etc/ssh/ssh_host_rsa_key. Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. The key fingerprint is: c1:dc:54:6c:45:d8:35:c3:cf:ac:fb:35:22:6a:2e:0e root@c7947be2eb9d The key's randomart image is: +--[ RSA 2048]----+ | .o.=++.| | o o + ..o| | + .. o.| | . +| | S . | | . | | E . . o.| | .. .. . o o| | ..+o ..| +-----------------+ Enter passphrase (empty for no passphrase): Enter same passphrase again: ---> 0f71202ee047 Removing intermediate container d7131a2534c2 Step 10/12 : RUN mkdir /var/run/sshd ---> Running in e3f36ab8616f ---> 6007b08d3e2b Removing intermediate container e3f36ab8616f Step 11/12 : EXPOSE 22 ---> Running in 653c57effb5a ---> 6533c53d9497 Removing intermediate container 653c57effb5a Step 12/12 : CMD /usr/sbin/sshd -D ---> Running in 46accc61a713 ---> 265bd8a128b3 Removing intermediate container 46accc61a713 Successfully built 265bd8a128b3 Successfully tagged curiousby/centos-ssh-root:original
37.2.4 build 验证
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信 以及扣扣群),没钱捧个人场,谢谢各位。
个人主页:http://knight-black-bob.iteye.com/
谢谢您的赞助,我会做的更好!
相关推荐
离线环境下,在centos7.6系统上安装docker-ce-19.03,nvidia-docker2.4版本,其中docker-ce-19.03在docker-local.tar压缩文件里面,nvidia-docker2在nvidia-docker2.zip文件中。 具体安装流程如下: 1.安装docker ...
说明:在最小化CentOS Linux release 7.6.1810 中制作yum源,docker-ce是centos 7系统x86架构rpm包。 使用: 1、上传文件到/data/docker-ce解压,或者任意目录后修改docker-ce-26.1.0.repo 中baseurl路径。 2、mv ...
[root@localhost docker-ce.19.3]# yum -y localinstall *.rpm ``` 这里的`*`表示匹配目录下的所有rpm文件,包括`containerd.io`、`docker-ce`和`docker-ce-cli`。 ##### 4. 启动与验证 安装完成后,启动Docker...
docker-ce-17.03.2.ce-1.el7.centos.x86_64 Centos7 离线安装包和依赖包、 audit-libs-python-2.7.6-3.el7.x86_64.rpm checkpolicy-2.5-4.el7.x86_64.rpm docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm docker-ce-...
我们在安装服务器的时候,很多情况都是局域网,没有外网,安装软件特别的麻烦,主要的问题就是依赖包,所以整理资源和教程。...1.Centos7-x86架构下离线安装docker与docker-compose的教程 2.安装需要的rpm包以及依赖包
解压上传到服务器 安装docker sh install.sh docker-18.03.1-ce.tgz 卸载docker sh uninstall.sh 安装docker-compose sh docker-compose.sh docker-compose-Linux-x86_64 如有不明白的欢迎随时咨询
也可以自己手动下载最新包,下载方法如下: mkdir /apps/docker-ce-v18 yum install --downloadonly --downloaddir=/apps/docker-ce-v18 \ yum-utils device-mapper-persistent-data lvm2 createrepo \ libseccomp ...
这通常包括`docker-ce`, `docker-ce-cli`, 和`containerd.io`等组件。确保你已经包含了所有必要的文件,并将它们放入一个压缩包中,例如我们这里提到的`docker-ce-20.10.12`。 2. **上传到服务器**:将包含所有RPM...
docker-ce-20.10.13-3.el7.x86_64.rpm containerd.io-1.5.10-3.1.el7.x86_64.rpm docker-ce-cli-20.10.13-3.el7.x86_64.rpm docker-ce-rootless-extras-20.10.13-3.el7.x86_64.rpm docker-ce-selinux-17.03.3.ce-1....
centos 7 离线安装docker-engine-1.12.6 yum localinstall *.rpm Installing : docker-engine-1.12.6-1.el7.centos.x86_64 8/8 Verifying : libsemanage-python-2.5-11.el7.x86_64 1/8 Verifying : setools...
3. 启动并启用NVIDIA Docker插件:`sudo systemctl start nvidia-docker-plugin && sudo systemctl enable nvidia-docker-plugin` 4. 验证安装:`docker run --rm --gpus all nvidia/cuda:10.0-base nvidia-smi` ...
Linux-centos-docker安装-habor私库搭建
tar -zxvf docker-19.03.9.tgz 进入解压后的文件夹,并使用rpm命令进行安装。例如: bash cd docker-19.03.9 rpm -Uvh *.rpm --nodeps --force 注意:这将会自动安装所有依赖项并强制覆盖已有的文件。
3、docker和docker-compose安装要提前安装完成 4、将下载内容解压一个目录 5、运行 docker-compose up # 此命令环境会在终端前台运行 docker-compose up -d # 加上-d会放入后台进行环境的启动 如有问题,欢迎进行...
CentOS-7-x86_64-Everything-1804 百度云盘资源路径!请笑纳 准备工作 1)下载VMware workstation12 百度云盘 链接:https://pan.baidu.com/s/1c6tE2cPy63y1vO1idHtAzw 提取码:duvd 2)下载CentOS7 方案一:...
centos7.4+ nvidia-docker2 安装所需要的必备包之一 libnvidia-container-tools-1.0.2-1.x86_64.rpm libnvidia-container1-1.0.2-1.x86_64.rpm nvidia-container-runtime-2.0.0-3.docker18.09.6.x86_64.rpm nvidia-...
consol/centos-xfce-vnc 采用VNC或者浏览器 firefox/chrome 都可以连接。启动命令: docker run --rm -it -p 5901:5901 -p 6901:6901 --name test_cent_os consol/centos-xfce-vnc。默认密码 vncpassword
CentOS下的docker-ce 18.06.1。docker-18.06.1-ce.tgz
sudo yum install -y docker-ce docker-ce-cli containerd.io ``` 5. 启动Docker服务并设置开机启动: ```bash sudo systemctl start docker sudo systemctl enable docker ``` 接下来,我们处理NVIDIA-...
docker export做的镜像,需要cat centos_x86.tar |docker import - centos7:x86导入