简体   繁体   English

连接到Docker的运行容器

[英]connect to docker's running container

I downloaded centos/centos7.1.1503 from docker's official hub, and created my custom dockerfile as below. 我从Docker的官方中心下载了centos / centos7.1.1503,并如下创建了我的自定义dockerfile。

FROM centos:centos7.1.1503
RUN yum install -y passwd
RUN echo -e “root\nroot” | (passwd --stdin root)
RUN yum update -y
RUN yum install -y git-core build-essential libssl-dev
CMD /var/tmp | git clone git://git.openwrt.org/14.07/openwrt.git

I then ran the following 3 commands 然后我运行了以下3个命令

docker build -t centos:test
docker run centos:test
docker attach <containerid>

It asks me for a password. 它要求我输入密码。 The password i set in the docker file doesn't work at all. 我在docker文件中设置的密码根本不起作用。 Any idea? 任何想法?

An idea is to change this line 一个想法是改变这一行

RUN echo -e “root\nroot” | (passwd --stdin root)

to this one: 对此:

RUN echo root | passwd root --stdin

Otherwise you are trying to set root\\nroot as your root password (including that strange newline). 否则,您尝试将root\\nroot设置为root密码(包括该奇怪的换行符)。

An other try would be this (if you have xargs available): 另一个尝试是这样(如果您有xargs可用):

RUN echo root | xargs passwd root

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将运行在 Docker 容器中的 Flyway 连接到运行在 Docker 容器中的数据库? - How to connect Flyway running in a Docker container to a database running in a Docker container? Docker容器,运行PostgreSQL不允许来自另一个容器的php pg_connect - Docker container, running PostgreSQL not allowing php's pg_connect from another container 如何通过运行带有URL的docker容器来连接docker容器中的python应用 - how to connect python app in docker container with running docker container with url 将在 Ubuntu VM 内运行的 docker 容器端口与 VM 的主机网络连接 - Connect a docker's container port that is running inside an Ubuntu VM, with the VM's host machine network docker-通过http连接到正在运行的容器 - docker - connect over http to running container 从主机连接到运行MongoDB的Docker容器 - Connect from host to Docker container running MongoDB 无法连接到在Docker容器中运行的oracledb - can not connect to oracledb running in a docker container 微服务无法连接到 Docker 容器中运行的 MySQL - Microservice can not connect to MySQL running in Docker container 如何连接到运行在 docker 容器中的 netcat? - How to connect to netcat running in docker container? 运行Tomcat尝试连接到Docker容器时出错 - Error running Tomcat trying to connect to a Docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM