简体   繁体   中英

Running a Docker file stored locally

I have a docker file that includes a python script. So far I pushed it to my github and from there to my docker hub. Afterwards I used the command

docker pull name/repo

I would like to store the docker file I created with a text editor in a folder together with the python scrip and execute it with a command like

docker run c:/pathtodockerfile

Is that possible?

The process to run Dockerfile is:

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

And then:

docker run -d tag

This works well in 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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM