原创文章,转载请注明出处
https://qiedd.com/
这里使用的 Ubuntu:18.04 的镜像,需要在原有的镜像上进行构建
# 创建文件 vim /root/Dockerfile/ubuntu
Dockerfile
# Dockerfile FROM ubuntu:18.04 RUN apt update -y && apt -y install openssh-server vim sudo apt-utils ENTRYPOINT service ssh restart && bash
构建镜像以及部署
# 构建镜像
docker build -f /root/Dockerfile/ubuntu -t ubuntu:ssh .
# 创建macvlan
docker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 \
-o parent=enp10s0 macvlan
# 启动容器
docker run -itd -h ubuntu --name ubuntu --network macvlan --ip 192.168.1.2 \
--restart=unless-stopped \
ubuntu:ssh
# 进入容器
docker exec -it ubuntu bash
# 修改sshd配置
vim /etc/ssh/sshd_config
# 把PerminRootLogin改为yes
PermitRootLogin yes
# 重新启动ssh
service ssh restart
# 设置密码
passwd
0 条评论