我正在看这样的Docerfile:
FROM microsoft/aspnetcore:2.0 AS base
# Install the SSHD server
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssh-server \
&& mkdir -p /run/sshd \
&& echo "root:Docker!" | chpasswd
#Copy settings file. See elsewhere to find them.
COPY sshd_config /etc/ssh/sshd_config
COPY authorized_keys root/.ssh/authorized_keys
# Install Visual Studio Remote Debugger
RUN apt-get install zip unzip
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg
EXPOSE 2222
我正在尝试使用此dockerfile创建映像。我怎样才能做到这一点?在过去的几个小时中,我已经阅读了许多网页这个https://odewahn.github.io/docker-jumpstart/building-images-with-dockerfiles.html,但是由于我的研究告诉我只需要一个命令,它们似乎都使它变得过于复杂。
答案 0 :(得分:0)
如果Dockerfile
在当前目录中,则此命令将构建映像并将其存储在本地:
docker build -t "app:latest" .
Here is documentation for build
command
然后,您可以在后台运行它:
docker run -d -p 2222:2222 app
此命令将创建容器并启动它。 Here is documentation for run
command。
答案 1 :(得分:0)
我不太确定您认为该网站上的“过于复杂”吗?
该站点上有一个命令为docker build -t "simple_flask:dockerfile" .
。唯一的麻烦是它添加了一个标签,该标签直接在其下进行解释
可能唯一更简单的方法是不对其进行标记。所以你做
docker build .
这意味着:为我建立一个形象。在当前目录中。
答案 2 :(得分:0)
由于拥有Docker文件,因此需要执行4个附加步骤:
docker build -t <app-name> .
:构建图像
docker images
:检查图像
docker run -d -p 2222:8080 myapp
:运行图像
docker ps
:检查正在运行的docker映像
请参考Docker doc.以获取更多详情