下载基础镜像
wget https://repo.openeuler.org/openEuler-20.03-LTS/docker_img/x86_64/openEuler-docker.x86_64.tar.xz
docker load < openEuler-docker.x86_64.tar.xz
docker images
docker run -it --rm --name openeuler_bash openeuler-20.03-lts:latest /bin/bash
# 默认没有设置yum源, 也没有安装vi, 先设置下yum源
echo "[base]" >> /etc/yum.repos.d/openEuler_x86_64.repo
echo "name=openEuler20.03LTS" >> /etc/yum.repos.d/openEuler_x86_64.repo
echo "baseurl=https://repo.openeuler.org/openEuler-20.03-LTS/OS/x86_64/" >> /etc/yum.repos.d/openEuler_x86_64.repo
echo "enabled=1" >> /etc/yum.repos.d/openEuler_x86_64.repo
echo "gpgcheck=0" >> /etc/yum.repos.d/openEuler_x86_64.repo
yum update
编写docker文件
Dockerfile
FROM openeuler-20.03-lts
MAINTAINER ykuang <ykuang@wapache.org>
ADD openEuler_x86_64.repo /etc/yum.repos.d/
ADD entrypoint.sh /
RUN ["yum", "update"]
RUN ["yum", "install", "-y", "vim", "wget", "iproute", "passwd"]
RUN echo 'root' | passwd --stdin root
RUN ["ssh-keygen", "-A"]
EXPOSE 22
ENTRYPOINT /entrypoint.sh
openEuler_x86_64.repo
[base]
name=openEuler20.03LTS
baseurl=https://repo.openeuler.org/openEuler-20.03-LTS/OS/x86_64/
enabled=1
gpgcheck=0
entrypoint.sh
#!/bin/bash
/usr/sbin/sshd
# FIXME 没有想到更好的办法防止docker自动退出
for ((;;))
do
sleep 1
done
构建镜像
docker build -t wapache/openeuler .
运行镜像
docker run --name euler -d -p 2222:22 wapache/openeuler
测试sshd服务
ssh root@localhost -p 2222
进入容器
docker exec -it euler bash