你能帮我吗?
我正在尝试通过dockerfile运行容器,但它显示了这一点 警告,我的容器无法启动。
compose.parallel.parallel_execute_iter:完成处理: <容器:远程启动远程主机...完成
compose.parallel.feed_queue:待处理:set()
compose.parallel.parallel_execute_iter:完成处理:<服务: remote_host>
compose.parallel.feed_queue:待处理:set()
附加到远程主机上的妖怪
compose.cli.verbose_proxy.proxy_callable:泊坞窗日志<- ('f2e305942e57ce1fe90c2ca94d3d9bbc004155a136594157e41b7a916d1ca7de', stdout = True,stderr = True,stream = True,关注= True)
远程主机|无法加载主机密钥:/ etc / ssh / ssh_host_rsa_key 远程主机|无法加载主机密钥:/ etc / ssh / ssh_host_ecdsa_key 远程主机|无法加载主机密钥: / etc / ssh / ssh_host_ed25519_key远程主机| sshd:没有主机密钥 可用-正在退出。
compose.cli.verbose_proxy.proxy_callable:泊坞窗事件<- (filters = {'label':['com.docker.compose.project = jenkins', 'com.docker.compose.oneoff = False']},decode = True)
我的dockerfile是这样的:
FROM centos RUN yum -y install openssh-server RUN yum install -y passwd RUN useradd remote_user &&
回声“ 1234” | passwd remote_user --stdin &&
mkdir /home/remote_user/.ssh &&
chmod 700 /home/remote_user/.ssh COPY remote_user.pub /home/remote_user/.ssh/authorized_keys RUN chown remote_user:远程用户-R / home / remote_user &&
chmod 400 /home/remote_user/.ssh/authorized_keys CMD / usr / sbin / sshd -D
答案 0 :(得分:0)
以一个空目录开头,然后在该目录中放置一个名为Dockerfile的文件
FROM centos
RUN yum -y install openssh-server
RUN yum install -y passwd
RUN useradd remote_user
RUN echo "1234" | passwd remote_user --stdin
RUN mkdir /home/remote_user/.ssh
RUN chmod 700 /home/remote_user/.ssh
COPY remote_user.pub /home/remote_user/.ssh/authorized_keys
RUN chown remote_user:remote_user -R /home/remote_user
RUN chmod 400 /home/remote_user/.ssh/authorized_keys
CMD /usr/sbin/sshd -D
# CMD ["/bin/bash"]
# ... save this file as Dockerfile then in same dir issue following
#
# docker build --tag stens_centos . # creates image stens_ubuntu
#
# docker run -d stens_centos sleep infinity # launches container and just sleeps only purpose here is to keep container running
#
# docker ps # show running containers
#
#
# ... find CONTAINER ID from above and put into something like this
#
# docker exec -ti $( docker ps | grep stens_centos | cut -d' ' -f1 ) bash # login to running container
#
然后在同一目录中,将ssh密钥文件按照
eve@milan ~/Dropbox/Documents/code/docker/centos $ ls -la
total 28
drwxrwxr-x 2 eve eve 4096 Nov 2 15:20 .
drwx------ 77 eve eve 12288 Nov 2 15:14 ..
-rw-rw-r-- 1 eve eve 875 Nov 2 15:20 Dockerfile
-rwx------ 1 eve eve 3243 Nov 2 15:18 remote_user
-rwx------ 1 eve eve 743 Nov 2 15:18 remote_user.pub
然后找出Dockerfile,然后将其解释并复制并粘贴到Dockerfile文件底部的命令...对我来说,所有这些命令都可以正常工作
在我复制并粘贴在Dockerfile底部列出的那些命令之后,容器便被构建并执行
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0a06ebd2752a stens_centos "sleep infinity" 7 minutes ago Up 7 minutes pedantic_brahmagupta
请记住,您必须在Dockerfile中定义底部的CMD或类似的值,以使其成为您希望在容器运行时执行的命令,该容器通常是根据定义永久运行的服务器...或者,此CMD可以仅仅是它将运行,然后像批处理作业一样完成,在这种情况下,容器将在该作业完成时退出...以此为基础,我建议您确认sshd -D
将作为服务器保留该命令,或者在启动容器时立即终止< / p>
答案 1 :(得分:0)
我刚刚回复了此GitHub issue,但这是我的经验以及如何解决
我刚在我的Jekyll博客网站上遇到了这个问题,通常我在创建新帖子时使用带有映射卷的docker-compose进行重建,因为它挂起了,试图用{{ 1}}切换并看到相同的docker-compose up
。
我在Macbook上试过了,效果很好
我没有打开任何实验性功能,但是我需要进入(在Windows上)设置->资源->文件共享,并在docker compose中添加我正在映射的文件夹(我博客的根目录)网站)
重新运行docker compose并立即启动并运行
版本信息: