[英]How to launch a Docker container that i've got from another person?
I am a Docker-newbie and I've got a project from another developer including a Dockerfile. 我是Docker-newbie,我有另一个开发人员的项目,包括Dockerfile。 This shall give me the Virtual Machine to continue work with the (nodeJS-) project inside this project folder.
这将给我虚拟机继续使用此项目文件夹中的(nodeJS-)项目。
Docker is already installed on my machine. Docker已安装在我的机器上。 How can I launch this container now?
我现在该如何启动此容器?
I've read about a command 我读过一个命令
sudo docker run -name my_first_instance
but i can't find any container name in the Dockerfile. 但我在Dockerfile中找不到任何容器名称。
The dockerfile
will create an image
for you that you can launch containers
from. dockerfile
将为您创建一个可以从中启动containers
的image
。 this being said , Follow this: 这就是说,按照这个:
Create a folder. 创建一个文件夹。
Copy dockerfile
in the folder 复制文件夹中的
dockerfile
cd into the folder execute the following command: cd进入该文件夹执行以下命令:
docker build -t <your desired image name> .
This will create an image
using directives in the dockerfile
in the current folder. 这将使用当前文件夹中
dockerfile
中的指令创建一个image
。
Now launch a container
from the image. 现在从图像中启动一个
container
。
docker run -d --name <your container name> <imagename from previous step> <optional startup commands>
Useful docker
commands: 有用的
docker
命令:
You can expose ports in the previous command using -p
switch. 您可以使用
-p
开关在上一个命令中公开端口。
You can list Images via docker images
您可以通过
docker images
列出docker images
You can list running containers via docker ps
您可以通过
docker ps
列出正在运行的容器
you can list running + exited containers via docker ps -a
你可以通过
docker ps -a
列出运行+退出的容器
have a look at 看一下
https://hub.docker.com/_/node/ https://hub.docker.com/_/node/
it is the official repository for NodeJS docker images 它是NodeJS docker镜像的官方存储库
If you want some docker images based on NodeJS, you will need to pull them docker pull my_node_image
如果你想要一些基于
docker pull my_node_image
,你需要将它们docker pull my_node_image
Then you can launch one with such a command 然后你可以使用这样的命令启动一个
docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app -w /usr/src/app node:4 node your-daemon-or-script.js
The Dockerfile is just the recipe to build a docker image, for Nginx, Mysql, MongoDb, Redis, Wordpress, Spotify, atop, htop... Dockerfile只是构建docker镜像的配方,适用于Nginx,Mysql,MongoDb,Redis,Wordpress,Spotify,atop,htop ......
If docker images
shows nothing, it means you have not yet pulled any docker image. 如果
docker images
没有显示任何内容,则表示您尚未提取任何泊坞窗图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.