[英]Stuck on starting a Docker container
I'm taking my first steps with Node.js and wrap my head around Docker and following the guide here https://www.docker.com/blog/getting-started-with-docker-using-node-jspart-i/ I successfully create the Docker image as logged on terminal I'm taking my first steps with Node.js and wrap my head around Docker and following the guide here https://www.docker.com/blog/getting-started-with-docker-using-node-jspart-i/ I successfully在终端上创建 Docker 映像
vinnytwice@Vinnys-iMac fixit_server_node % docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
node-docker latest 483e8ea7d5e8 2 minutes ago 950MB
node 15.14.0 3d3f41722daf 3 days ago 936MB
but then the I try to run it with docker run node-docker
as the guide says但是然后我尝试使用
docker run node-docker
After running this command you'll notice that you were not returned to the command prompt
运行此命令后,您会注意到您没有返回到命令提示符
but nothing happens and instead I'm indeed returned to the prompt..但什么也没发生,相反,我确实回到了提示符..
vinnytwice@Vinnys-iMac fixit_server_node % docker run node-docker
vinnytwice@Vinnys-iMac fixit_server_node %
I suppose there is something wrong in my Dockerfile
as I'm using my own app and not cloning the one from the guide.我想我的
Dockerfile
有问题,因为我使用的是自己的应用程序,而不是从指南中克隆应用程序。 Here is my Dockerfile
:这是我的
Dockerfile
:
FROM node:15.14.0
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm install
# If you are building your code for production
# RUN npm ci --only=production
# Bundle app source
COPY . .
EXPOSE 8080
CMD [ "node", "index.js" ]
As when I start my app I use nodemon server.js
I tried changing to CMD [ "nodemon", "server.js" ]
but still the same result..当我启动我的应用程序时,我使用
nodemon server.js
我尝试更改为CMD [ "nodemon", "server.js" ]
但仍然是相同的结果..
You should list the running processes to see if it is indeed running.您应该列出正在运行的进程以查看它是否确实在运行。
Unless I'm reading bad, this seems to be just a correct behavior, you're starting a docker container, not asking to get inside it.除非我读错了,这似乎只是一个正确的行为,你正在启动一个 docker 容器,而不是要求进入它。
docker container ls
This will show the running processes.这将显示正在运行的进程。 More info here: https://docs.docker.com/engine/reference/commandline/container_ls/
更多信息: https://docs.docker.com/engine/reference/commandline/container_ls/
Once you start a container, you can connect into it, like in a SSH connection.启动容器后,您可以连接到它,例如 SSH 连接。
docker exec -it <container name> /bin/bash
Next time you can try to start the container and connect at the same time:下次可以尝试同时启动容器和连接:
docker run -it --name <container name>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.