Reputation: 6346
I'm new to docker, and I have some issues with the process of pushing images into a private registry and pulling them by docker-compose.yml file in another computer in our office.
I have 2 folders in my project: nginx, and client.
The nginx, is the server, and the client is create-react-app.
nginx folder:
default.conf:
upstream client {
server client:3000;
}
server {
listen 80;
location / {
proxy_pass http://client;
}
location /sockjs-node {
proxy_pass http://client;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
FROM nginx
COPY ./default.conf /etc/nginx/conf.d/default.confd
client folder:
nginx/default.conf:
server {
listen 3000;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
Dockerfile:
FROM node:alpine as builder
ARG REACT_APP_NODE_ENV
ENV REACT_APP_NODE_ENV $REACT_APP_NODE_ENV
WORKDIR /app
COPY ./package.json ./
RUN npm i
COPY . .
RUN npm run build
FROM nginx
EXPOSE 3000
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/build /usr/share/nginx/html
Outside of the 2 folders, i have the docker-compose.yml file:
version: '3'
services:
nginx:
restart: always
build:
dockerfile: Dockerfile
context: ./nginx
ports:
- '3050:80'
client:
build:
context: ./client
dockerfile: Dockerfile
args:
- REACT_APP_NODE_ENV=production
volumes:
- /app/node_modules
- ./client:/app
When I do inside the project folder "docker-compose up --build" everything works as I expect.
Now, I want to push the images and pull them on another computer in the office.
I first pushed the 2 images (nginx, and the client) to the registry by the following commands on the terminal:
docker build -t orassayag/osr_streamer_nginx:v1.0 .
docker tag orassayag/osr_streamer_nginx:v1.0 <office_ip_address>:5000/orassayag/osr_streamer_nginx:v1.0
docker push <office_ip_address>:5000/orassayag/osr_streamer_nginx:v1.0
docker build -t orassayag/osr_streamer_client:v1.0 .
docker tag orassayag/osr_streamer_client:v1.0 <office_ip_address>:5000/orassayag/osr_streamer_client:v1.0
docker push <office_ip_address>:5000/orassayag/osr_streamer_client:v1.0
Then, I updated my docker-compose.yml file as the following:
version: '3'
services:
nginx:
image: <office_ip_address>:5000/orassayag/osr_streamer_nginx
restart: always
build:
context: ./nginx
dockerfile: Dockerfile
ports:
- '3050:80'
client:
image: <office_ip_address>:5000/orassayag/osr_streamer_client
build:
context: ./client
dockerfile: Dockerfile
args:
- REACT_APP_NODE_ENV=production
volumes:
- /app/node_modules
- ./client:/app
I went to other computer, created a folder name "TestDeploy", and on terminal I run "docker-compose build --pull", and I get the following error:
"ERROR: build path C:\Or\Web\StreamImages\TestDeploy\nginx either does not exist, is not accessible, or is not a valid URL."
What am I doing wrong?
I need help.
Upvotes: 1
Views: 901
Reputation: 159438
You need to remove the build:
blocks in your deployment environment, or else Docker Compose will try to build the images rather than pulling them. You also need to remove the volumes:
there or else it will expect to find source code locally instead of in the image.
(My personal recommendation would be to remove those volumes:
everywhere, do development outside of Docker, and have your Docker setup accurately reflect your deployment environment, but I seem to be in a minority on this.)
Upvotes: 2