When I try to run ' docker-compose up" the command prompt throws the below error :
$ docker-compose up
Building tomcat
unknown flag: --iidfile
See 'docker build --help'.
ERROR: Service 'tomcat' failed to build
Below is the Dockerfile and docker-compose.yml file:
$ cat Dockerfile.dev
FROM node:alpine
WORKDIR '/app'
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "run", "start"] `
$ cat docker-compose.yml
version: '3'
services:
tomcat:
restart: always
build:
context: .
dockerfile: Dockerfile.dev
ports:
- "3000:3000"
volumes:
- /app/node_modules
- .:/app
tests:
restart: always
build:
context: .
dockerfile: Dockerfile.dev
volumes:
- /app/node_modules
- .:/app
command: ["npm", "run", "test"]
Do I have something wrong configuration in Dockerfile or docker-compose.yml?
I faced the same problem when using docker-compose 1.29.1. Downgrading to docker-compose 1.26.2 resolved this problem.
reinstall docker-compose 1.26.2
rm -f /usr/local/bin/docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
Faced the same issue. Removed docker and installed docker-ce. This helped me to solve the issue.
Related
I try to run both React and Nest apps with docker-compose up, but it fails while running the server.
However, there is not problems when starting 2 containers separately.
The error is:
server | Unknown command: "start:dev"
server |
server | Did you mean one of these?
server | npm run start:dev # run the "start:dev" package script
docker-compose.yml:
version: "3"
services:
client:
container_name: client
build:
context: ./client
dockerfile: Dockerfile
image: client
ports:
- "3000:3000"
volumes:
- ./client:/app
server:
container_name: server
build:
context: ./server
dockerfile: Dockerfile
image: server
ports:
- "8080:8080"
volumes:
- ./server:/app
Server Dockerfile:
FROM node:16
WORKDIR ./app
COPY package.json ./
RUN npm install
COPY . .
ENV PORT=8080
EXPOSE 8080
CMD ["npm", "run", "start:dev"]
Client Dockerfile:
FROM node:16
WORKDIR ./app
COPY package.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
The issue is with docker-compose.yml, but I can't see if it's connected to nest or docker.
Thank you for the help in advance.
my project structure is defined like this (names are just for example):
- docker-compose.yml
- env_files
- foo.env
- dockerfiles
-service_1
-foo.Dockerfile
-requirements.txt
- code_folder_1
- ...
- code_folder_2
- ...
In my docker-compose:
some_service:
container_name: foo_name
build:
context: .
dockerfile: ./dockerfiles/service_1/foo.Dockerfile
ports:
- 80:80
env_file:
- ./env_files/foo.env
Dockerfile:
FROM python:3.8-slim
WORKDIR /some_work_dir
COPY ./dockerfiles/intermediary/requirements.txt .
RUN pip3 install --upgrade pip==21.3.1 && \
pip3 install -r requirements.txt
COPY . .
EXPOSE 80
And after i run docker compose build in the directory where compose file is located I get this error:
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount4158855397/Dockerfile: no such file or directory
I really do not understand why this is happening. I need to set context:. because I have multiple folders that I need to COPY inside foo.Dockerfile
Same error was replicated in macOS Monterey 12.5.1 and Ubuntu 18.04.4 LTS (Bionic Beaver)
I solved a similar issue by writing a script like the following:
#!/bin/bash
SCRIPT_PATH=$(readlink -f $(dirname $0))
SCRIPT_PATH=${SCRIPT_PATH} docker-compose -f ${SCRIPT_PATH}/docker-compose.yaml up -d --build $#
And changing the yaml into:
some_service:
container_name: foo_name
build:
context: .
dockerfile: ${SCRIPT_PATH}/dockerfiles/service_1/foo.Dockerfile
ports:
- 80:80
env_file:
- ${SCRIPT_PATH}/env_files/foo.env
I am trying to create a docker image with node.js version 16. However I failed to find solution to this problem despite searching stackoverflow and other platform.
So basically I am using docker compose up and this is how my docker-compose.yml looks like:
version: '3.1'
services:
redis:
image: 'redis:alpine'
ports:
- "6379:6379"
webserver:
image: 'nginx:alpine'
working_dir: /application
volumes:
- '.:/application'
- './docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf'
ports:
- '3000:80'
php-fpm:
build: docker/php-fpm
working_dir: /application
volumes:
- '.:/application'
- './docker/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini'
node:
build: docker/node
working_dir: /application
volumes:
- './:/application'
ports:
- '8080:8080'
The files are living in docker folder with 3 nested folders.
node/Dockerfile:
FROM node:16
WORKDIR /application
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD ["npm", "start"]
The npm start command consists of npm install and a postinstall where simply npm run dev would be executed.
Unfortunatley, I get the following error
Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin/sh -c 'cd /application && npm install'": stat /bin/sh -c 'cd /application && npm install': no such file or directory: unknown
Also I want to add is, I am running this under WSL2.
I am trying to dockerize my node app but I can't seem to understand why it can't find the package.json file because the package.json file is in the same path as the docker compose and dockerfile. Here is the folder structure:
Below is the dockerfile:
Dockerfile
FROM node:12
# RUN mkdir -p ./usr/src/app/
COPY . /usr/src/app/
WORKDIR /usr/src/app/
# ADD package.json /usr/src/app/package.json
COPY package*.json ./
RUN yarn
RUN yarn global add pm2
COPY . .
EXPOSE 3005
EXPOSE 9200
CMD yarn start:dev
And the docker compose file:
docker-compose.yml
version: "3.6"
services:
api:
image: node:12.13.0-alpine
container_name: cont
build:
context: .
dockerfile: Dockerfile
ports:
- 3005:3005
environment:
- JWT_TOKEN_SECRET=ajsonwebtokensecret
- MONGO_URI=mongodb://localhost:27017/em
- PORT=3005
- MAIL_USER=******
- MAIL_PASS=******
- FORGOT_PASS_EMAIL=noreply#em.com
- CLIENT_SIDE_URL=http://localhost:3001
- ELASTICSEARCH_URI=http://localhost:9200
volumes:
- .:/usr/src/app/
command: yarn start:dev
links:
- elasticsearch
depends_on:
- elasticsearch
networks:
- esnet
elasticsearch:
container_name: em-elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
volumes:
- esdata:/usr/share/elasticsearch/data
environment:
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.type=single-node
logging:
driver: none
ports:
- 9300:9300
- 9200:9200
networks:
- esnet
volumes:
esdata:
networks:
esnet:
When i try to run docker compose up i get this error
cont | yarn run v1.19.1
cont | error Couldn't find a package.json file in "/"
cont | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this
command.
cont exited with code 1
I have tried this, but all solutions I have tried don't work. Does anyone have a solution to this?
Relative pathing. Note that the working COPY command is COPY . .. The . there means 'the current directory'. So what you need is:
COPY ./package*.json ./
You would simplify your debugging by running docker build -t scratch . to eliminate docker-compose from the equation. Always drive it down to absolute minimal reproducer to isolate the exact issue.
i will docker my app js. I run the order docker-compose up.
But i have error : app | /bin/sh: 1: [: “npm”,: unexpected operator.
Dockerfile
FROM node:latest
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
EXPOSE 3000
RUN ["npm", "start" ]
docker-compose.yml
version: "2"
services:
app:
container_name: app
restart: always
build: .
ports:
- "3000:3000"
links:
- mongo
mongo:
container_name: mongo
image: mongo
volumes:
- ./data:/data/db
ports:
- "27017:27017"
Double-check your Dockerfile.
"npm" is different from “npm”, notice the double quote " and “. You should
always use " (input from your keyboard) rather than “
then run the following command:
docker-compose up --build
You could use the CMD instruction instead of RUN.
Change this line:
RUN ["npm", "start"]
...to this:
CMD ["npm", "start"]
The CMD instruction is triggered when your container starts.
Docs here:
https://docs.docker.com/engine/reference/builder/#cmd
I hope this helps.