Dockerfile构建实战
Dockerfile指令如下;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # date 2021年6月7日18:04:48 # auto created ubuntu:18.04 # Email 2911811686@qq.com # by author limaolin # docker run -itd --name=linux-003 --privileged=true -p 6023:22 ubuntu18.04-ssh:v2 ################################## FROM ubuntu:18.04 MAINTAINER limaolin 2021-6-7 18:04:34 RUN apt update -y RUN apt full-upgrade -y RUN apt install net-tools vim ssh iputils-ping wget -y RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config WORKDIR /root EXPOSE 80 443 RUN update-rc.d ssh enable ENTRYPOINT ["/sbin/init"] RUN mkdir -pv /run/sshd RUN echo root:web123|chpasswd CMD /usr/sbin/sshd;/bin/bash RUN ls -al /run/ |
执行dockerfile
docker build -t ubuntu18.04-ssh:v1 -f Dockerfile .
制作过程
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | [root@Docker ubuntu18.04]# docker build -t ubuntu18.04-ssh:v1 -f Dockerfile . Sending build context to Docker daemon 2.56kB Step 1/14 : FROM ubuntu:18.04 ---> 81bcf752ac3d Step 2/14 : MAINTAINER limaolin 2021-6-7 18:04:34 ---> Running in f8392e282a0a Removing intermediate container f8392e282a0a ---> dfa9bd4447a9 Step 3/14 : RUN apt update -y ---> Running in 1acde5cfbf74 WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] Get:2 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB] Get:3 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1414 kB] Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Get:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB] Get:6 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB] Get:7 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [2184 kB] Get:8 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB] Get:9 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [24.7 kB] Get:10 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [450 kB] Step 4/14 : RUN apt install net-tools vim ssh iputils-ping wget -y ---> Running in 4205ab8a2514 WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Reading package lists... Building dependency tree... Reading state information... The following additional packages will be installed: ca-certificates dbus dmsetup file gir1.2-glib-2.0 krb5-locales libapparmor1 libargon2-0 libbsd0 libcap2 libcap2-bin libcryptsetup12 libdbus-1-3 libdevmapper1.02.1 libedit2 libexpat1 libgirepository-1.0-1 libglib2.0-0 libglib2.0-data libgpm2 libgssapi-krb5-2 libicu60 libidn11 libip4tc0 libjson-c3 libk5crypto3 libkeyutils1 libkmod2 libkrb5-3 libkrb5support0 libmagic-mgc libmagic1 libmpdec2 libnss-systemd libpam-cap libpam-systemd libpsl5 libpython3-stdlib libpython3.6 libpython3.6-minimal libpython3.6-stdlib libreadline7 libsqlite3-0 libssl1.0.0 libssl1.1 libwrap0 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxml2 libxmuu1 mime-support multiarch-support ncurses-term networkd-dispatcher openssh-client openssh-server openssh-sftp-server openssl publicsuffix python3 python3-certifi python3-chardet python3-dbus python3-gi python3-idna python3-minimal python3-pkg-resources python3-requests python3-six python3-urllib3 python3.6 python3.6-minimal readline-common shared-mime-info ssh-import-id systemd systemd-sysv ucf vim-common vim-runtime xauth xdg-user-dirs xxd xz-utils Get:89 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-urllib3 all 1.22-1ubuntu0.18.04.2 [86.2 kB] Get:90 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-requests all 2.18.4-2ubuntu0.1 [58.3 kB] Get:91 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 vim-runtime all 2:8.0.1453-1ubuntu1.4 [5435 kB] Get:92 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 vim amd64 2:8.0.1453-1ubuntu1.4 [1152 kB] Get:93 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 ssh-import-id all 5.7-0ubuntu1.1 [10.9 kB] debconf: delaying package configuration, since apt-utils is not installed Fetched 35.6 MB in 10s (3642 kB/s) Selecting previously unselected package libssl1.1:amd64. (Reading database ... 4045 files and directories currently installed.) Preparing to unpack .../libssl1.1_1.1.1-1ubuntu2.1~18.04.9_amd64.deb ... Unpacking libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.9) ... Selecting previously unselected package libpython3.6-minimal:amd64. Preparing to unpack .../libpython3.6-minimal_3.6.9-1~18.04ubuntu1.4_amd64.deb ... Unpacking libpython3.6-minimal:amd64 (3.6.9-1~18.04ubuntu1.4) ... Selecting previously unselected package libexpat1:amd64. Preparing to unpack .../libexpat1_2.2.5-3ubuntu0.2_amd64.deb ... Unpacking libexpat1:amd64 (2.2.5-3ubuntu0.2) ... Selecting previously unselected package python3.6-minimal. Preparing to unpack .../python3.6-minimal_3.6.9-1~18.04ubuntu1.4_amd64.deb ... Unpacking python3.6-minimal (3.6.9-1~18.04ubuntu1.4) ... Setting up libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.9) ... debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.) debconf: falling back to frontend: Readlin Step 12/14 : RUN echo root:web123|chpasswd ---> Running in 38c2342d8090 Removing intermediate container 38c2342d8090 ---> 0a426fa8eff0 Step 13/14 : CMD /usr/sbin/sshd;/bin/bash ---> Running in 08d81a0739bb Removing intermediate container 08d81a0739bb ---> 8f20c8feabf8 Step 14/14 : RUN ls -al /run/ ---> Running in b96740a4d0a6 total 36 drwxr-xr-x 1 root root 4096 Jun 7 10:22 . drwxr-xr-x 1 root root 4096 Jun 7 10:22 .. lrwxrwxrwx 1 root root 25 Jun 7 10:21 initctl -> /run/systemd/initctl/fifo drwxrwxrwt 1 root root 4096 Jun 7 10:21 lock drwxr-xr-x 2 root root 4096 Jun 7 10:21 log drwxr-xr-x 2 root root 4096 May 12 23:05 mount drwxr-xr-x 2 root root 4096 Jun 7 10:21 sendsigs.omit.d lrwxrwxrwx 1 root root 8 Jun 7 10:21 shm -> /dev/shm drwxr-xr-x 2 root root 4096 Jun 7 10:22 sshd drwxr-xr-x 1 root root 4096 Jun 7 10:21 systemd drwxr-xr-x 2 root root 4096 Jun 7 10:21 user -rw-rw-r-- 1 root utmp 0 May 12 23:05 utmp Removing intermediate container b96740a4d0a6 ---> 2ecb72fab0ef Successfully built 2ecb72fab0ef Successfully tagged ubuntu18.04-ssh:v1 [root@Docker ubuntu18.04]# |
赏
支付宝赞助
微信赞助