docker笔记
2020/03/05

build

docker build -t c_shell .

Dockerfile

#build ssh images
#
#VERSION        1.0

FROM ubuntu:16.04
MAINTAINER NSS/Czh

#更换国内源文件
COPY    ./sources.list /etc/apt/sources.list
RUN     apt-get update \
        && echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d \
        && DEBIAN_FRONTEND="noninteractive" apt-get install -y openssh-server \
        && rm -rf /var/lib/apt/lists/*
#设置用于ssh连接的root密码
RUN     useradd -m dluctf
RUN     echo 'dluctf:test'|chpasswd
RUN     mkdir -p /var/run/sshd
RUN     chown -R root:dluctf /home/dluctf && \
        chmod -R 750 /home/dluctf && \
        chmod 740 /home/dluctf/flag

#允许root连接
RUN     sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/g' /etc/ssh/sshd_config

EXPOSE  22
CMD     ["/usr/sbin/sshd", "-D"]

运行

docker run -d -p 10001:22 images_name

进入

sudo docker exec -i -t images_name /bin/sh
请杯咖啡呗~
支付宝
微信
本文作者:ios
版权声明:本文首发于ios的博客,转载请注明出处!