简体   繁体   English

如何启动我从另一个人那里获得的Docker容器?

[英]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将为您创建一个可以从中启动containersimage 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.

相关问题 如何从另一个 docker 容器连接到作为 docker 容器启动的 Verdaccio 服务? - How can I connect to my Verdaccio service launched as docker container from another docker container? 如何从一个docker容器向另一个链接容器发出HTTP请求? - How can I make a HTTP request from one docker container to another linked container? 如何将 docker 容器端口暴露给另一个容器 - How do I expose a docker container port to another container 如何从 AWS SAM 本地 Docker 容器访问另一个 Docker 容器(运行节点快速服务器)? - How do I access another Docker container (running a node express server) from a AWS SAM Local Docker container? 如何将文件从当前Docker容器复制到另一个容器 - How copy files from current docker container to another container 如何使用webpack启动应用程序以在Docker容器中进行生产? - How to launch app with webpack for production in Docker container? 如何在Docker中将数据从一个容器获取到另一个容器? 我收到ECONNREFUSED错误 - How can I get data from one container to another in docker? I am getting ECONNREFUSED error 我遇到了 ReactJS 从 Nodejs 下载文件的问题 - I've got an issue with ReactJS to download a file from Nodejs 如何连接到docker容器的localhost(从容器内部) - How do I connect to the localhost of a docker container (from inside the container) 如何从另一个 docker 容器访问一个 docker 容器的快速路由 - How to get access to express routes of a docker container from another docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM