antony@notes:~/container$ cat "Untitled-8.md"
Untitled
$ echo 'FROM alpine:3.14.0
RUN apk update && apk upgrade && apk add --no-cache nano sudo wget curl \
tree elinks bash shadow procps util-linux coreutils binutils findutils grep && \
wget https://busybox.net/downloads/binaries/1.28.1-defconfig-multiarch/busybox-x86_64 && \
chmod +x busybox-x86_64 && mv busybox-x86_64 bin/busybox1.28 && \
mkdir -p /opt/www && echo "let me go" > /opt/www/index.html
CMD ["/bin/bash"] ' > base/Dockerfile
CMD ["/bin/bash"]: container要指定他要執行的命令,如果docker run沒有指定命令,就由Docker image裡面的CMD來幫我們決定要run哪個命令。 FROM=> 拿誰的光碟 RUN=> 把要對光碟片做的改裝,丟進rootfs CMD=> 使用者沒給指令時的image預設指令
- 只要在大機房裡面,
$ echo $'FROM alpine.base
RUN apk update && \
apk add --no-cache openssh-server tzdata && \
# 設定時區
cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime && \
ssh-keygen -t rsa -P "" -f /etc/ssh/ssh_host_rsa_key && \
echo -e 'Welcome to ALP SSHd 6000\n' > /etc/motd && \
# 建立管理者帳號 bigred
adduser -s /bin/bash -h /home/bigred -G wheel -D bigred && echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \
echo -e "bigred\nbigred\n" | passwd bigred &>/dev/null && \
rm /sbin/reboot && rm /usr/bin/killall
EXPOSE 22
ENTRYPOINT ["/usr/sbin/sshd"]
CMD ["-D"] ' > sshd/Dockerfile
ENTRYPOINT: 這個宣告是說,以後我的image產生container不可以給命令,也就是在docker run後面, ENTRYPOINT ["/usr/sbin/sshd"] –強制指定container 使用的process,不論有無輸入執行的process。 CMD ["-D"] –當Dockerfile有ENTRYPOINT時,CMD做為輸入參數用,給ENTRYPOINT指定的process使用(這裡為sshd) -D 前景執行程式