运行本地存储的 Docker 文件

问题描述 投票:0回答:2

我有一个包含 python 脚本的 docker 文件。到目前为止,我已将其推送到我的 github,并从那里推送到我的 docker hub。后来我使用了命令

docker pull name/repo

我想将使用文本编辑器创建的 docker 文件与 python 脚本一起存储在一个文件夹中,并使用类似的命令执行它

docker run c:/pathtodockerfile

这可能吗?

docker dockerfile docker-image
2个回答
53
投票

运行Dockerfile的流程是:

docker build . -t [tag] -f /path/to/Dockerfile

然后:

docker run -d tag

1
投票

这在 macOS Monterey 中运行良好

docker build . --tag "cms" --file /Users/anjum/cms/Dockerfile 
  [+] Building 19.5s (10/13)                                                                                                                                                                
 => [internal] load build definition from Dockerfile                                                                                                                                 0.0s
 => => transferring dockerfile: 1.15kB                                                                                                                                               0.0s
 => [internal] load .dockerignore                                                                                                                                                    0.0s
 => => transferring context: 367B                                                                                                                                                    0.0s
 => [internal] load metadata for docker.io/library/node:12-slim                                                                                                                      8.4s
 => [auth] library/node:pull token for registry-1.docker.io                                                                                                                          0.0s
 => [1/8] FROM docker.io/library/node:12-slim@sha256:f23d5785b19e65224f2cd35f3cc6207d4de147d12d75b52d0dc8af2d507c7f51                                                                9.2s
 => => resolve docker.io/library/node:12-slim@sha256:f23d5785b19e65224f2cd35f3cc6207d4de147d12d75b52d0dc8af2d507c7f51                                                                0.0s
 => => sha256:b62f8e7e96f8d4168d3b9c1d1262ef7d8f78910f1e19cfedd1b7ce3ab5b7dffd 1.37kB / 1.37kB                                                                                       0.0s
 => => sha256:0eae9e0410e240f60b70b757f3c298786d7e334af266798171c11e4dbc1cc4d8 6.89kB / 6.89kB                                                                                       0.0s
 => => sha256:eec53b8a5053c739b5b685cb372b38eea3286ab6626532bad963291f76357c5f 22.53MB / 22.53MB                                                                                     3.9s
 => => sha256:d72ba3acf6e599d15655c136900ccf28e9e3810f1f483753ba1109351ff4e64f 4.17kB / 4.17kB                                                                                       0.8s
 => => sha256:5f97dde1af90835dff237728a22841d5967334a532b71898a151f2eb4ea51fb8 24.22MB / 24.22MB                                                                                     3.9s
 => => sha256:f23d5785b19e65224f2cd35f3cc6207d4de147d12d75b52d0dc8af2d507c7f51 776B / 776B                                                                                           0.0s
 => => sha256:9a16f71a1d56dbab6c2b8ef8fd1b530f808e847ddcc4e12f411abddcdf9d4b3d 2.78MB / 2.78MB                                                                                       2.6s
 => => sha256:053d0f2346070637fbb7ee095998009bf08a45549649603a2dbb2ccb40c73d70 461B / 461B                                                                                           3.2s
 => => extracting sha256:eec53b8a5053c739b5b685cb372b38eea3286ab6626532bad963291f76357c5f                                                                                            1.9s
 => => extracting sha256:d72ba3acf6e599d15655c136900ccf28e9e3810f1f483753ba1109351ff4e64f                                                                                            0.1s
 => => extracting sha256:5f97dde1af90835dff237728a22841d5967334a532b71898a151f2eb4ea51fb8                                                                                            1.9s
 => => extracting sha256:9a16f71a1d56dbab6c2b8ef8fd1b530f808e847ddcc4e12f411abddcdf9d4b3d                                                                                            0.2s
 => => extracting sha256:053d0f2346070637fbb7ee095998009bf08a45549649603a2dbb2ccb40c73d70                                                                                            0.0s
 => [internal] load build context                                                                                                                                                    4.7s
 => => transferring context: 77.76MB                                                                                                                                                 4.6s
 => [2/8] WORKDIR /usr/src/app                                                                                                                                                       0.3s
 => [3/8] COPY package.json ./                                                                                                                                                       0.0s
 => [4/8] RUN npm set unsafe-perm true 
© www.soinside.com 2019 - 2024. All rights reserved.