I create a 'docker' folder inside my php web app source code.
I placed a docker-composer.yml and a Dockerfile inside /docker
<project_root>
- app
- bootstrap
....
- docker
- docker-compose.yml
- Dockerfile
.....
- storage
So insider docker-composer.yml I am trying to do this
version: '3.9'
services:
app:
build:
context: ..
dockerfile: ./Dockerfile
image: my-custom-app-docker-image
container_name: app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www/app
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
The problem is that: running docker-composer up I got
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-mount61239487/Dockerfile: no such file or directory
Problem found, and fixed
I add a second dot to build.context
app:
build:
context: ..
changing third line to
context: .
worked
Related
I get the following error when running "docker compose up --detach". My Ubuntu distribution is 22.04, and I have ran this container on another system before without issues but switched laptops and now keep getting this error.
2022/11/02 15:20:09 http2: server: error reading preface from client //./pipe/docker_engine: bogus greeting "400 Bad Request: invalid"
> \[+\] Building 5.0s (2/2) FINISHED
> =\> ERROR \[internal\] load build definition from Dockerfile 5.0s
> =\> CANCELED \[internal\] load .dockerignore 5.0s
------
> \[internal\] load build definition from Dockerfile:
------
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: no active session for v0kttrdojvk121i286w61p0sb: context deadline exceeded
This is what my Dockerfile looks like:
FROM python:3.10.2-buster
WORKDIR /bfo_app
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
EXPOSE 5005
COPY . .
CMD ["python3", "run.py"]
And this is my docker-compose.yml
version: '3.9'
services:
db:
container_name: breakfastForOneDatabase
image: postgres:14.1-alpine
restart: always
env_file:
- dev.env
ports:
- "5432:5432"
volumes:
- db:/var/lib/postgresql/data
pgadmin:
container_name: pgadmin4
image: dpage/pgadmin4
restart: always
env_file:
- dev.env
ports:
- "5050:80"
web:
container_name: breakfastForOneFlask
env_file:
- dev.env
build: .
ports:
- "5005:5005"
volumes:
- .:/bfo_app
volumes:
db:
driver: local
I am expecting the containers to start. I have tried looking through a bunch of SO pages but nothing has worked. There are three containers that should be started but I get the error showed above.
I want to spin up two containers when I do docker-compose up
I have two folders API and front. Each has a Dockerfile and docker-compose file. currently, I have to do docker-compose up for each app.
like below
- api
- docker-compose.yml
- Dockerfile
- front
- docker-compose.yml
- Dockerfile
I want to have one docker-compose.yml to manage two containers like below.
- docker-compose.yml
- api
- Dockerfile
- front
- Dockerfile
api docker-compose
version: '3'
services:
api:
build: .
command: pipenv run start
image : data-tracker-backend
volumes:
- .:/api/
ports:
- "8000:8000"
front docker-compose
version: '3'
services:
web:
build: .
command: npm start
image : data-tracker-front
volumes:
- .:/front/
ports:
- "5000:5000"
I want to have something like
version: '3'
services:
api:
build: .
command: pipenv run start
image : data-tracker-backend
volumes:
- .:/api/
ports:
- "8000:8000"
front:
build: .
command: npm start
image : data-tracker-front
volumes:
- .:/front/
ports:
- "5000:5000"
help to access the command from the different working directories.
You can change the build directory and the volumes one.
version: '3'
services:
api:
build: ./api
volumes:
- ./api:/api
# the rest of your commands...
front:
build: ./front
volumes:
- ./front:/front
# the rest of your commands...
My suggestion though is to read the guidelines. It's plenty of information and tutorials there.
You can try to use build context and dockerfile as shown below
- docker-compose.yml
- api
- Dockerfile
- front
- Dockerfile
version: '3'
services:
api:
build:
context: api
dockerfile: Dockerfile
command: pipenv run start
image : data-tracker-backend
volumes:
- .:/api/
ports:
- "8000:8000"
front:
build:
context: front
dockerfile: Dockerfile
command: npm start
image : data-tracker-front
volumes:
- .:/front/
ports:
- "5000:5000"
I have an error when I try to build :
$ docker-compose build
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.web: 'dockerfile'
Here's the content of my docker-compose.yml file :
#docker-compose.yml
version: '2'
services:
db:
image: mysql
environment:
- MYSQL_DATABASE=db
- MYSQL_ROOT_PASSWORD=pwd
volumes:
- ./mysql:/var/lib/mysql
web:
build: .
dockerfile: dev.Dockerfile
entrypoint: ./script.sh db:3306 --
command: python manage.py runserver 0.0.0.0:8000
environment:
- DJANGO_SETTINGS_MODULE=db.docker_settings
- CELERY_ALWAYS_EAGER=True
volumes:
- .:/code
- /code/node_modules/
ports:
- "8000:8000"
depends_on:
- db
I tried looking here : https://docs.docker.com/compose/compose-file/compose-file-v2/
but couldn't find any solution.
Any clue on this ? I'm still a beginner with docker.
Remove the . after build:. Also, fix your indentation, like this:
build:
context: .
dockerfile: dev.Dockerfile
entrypoint: ./script.sh db:3306 --
...
there's a problem with your indentation in docker-compose.yaml, make following changes
web:
build:
dockerfile: dev.Dockerfile
entrypoint: ./script.sh db:3306 --
command: python manage.py runserver 0.0.0.0:8000
Hi I Have trying to run NIFI Apache on Docker using the DockerFile but i got error just like i attached in the Picture, is there any settings missing on the DockerFile?.
my Docker Compose File
version: '3.5'
services:
nifi:
build:
context: .
dockerfile: Dockerfile
args:
NIFI_VERSION: 1.8.0
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
ports:
- "8080:8080"
volumes:
- ./config/nifi/conf:/opt/nifi/nifi-current/conf
- ./config/nifi/data:/home/nifi/data/data
- ./config/nifi/script:/home/nifi/data/script
- ./config/nifi/utils:/home/nifi/data/utils
nifi-registry:
build:
context: .
dockerfile: Dockerfile.registry
args:
NIFI-REGISTRY-VERSION: 0.3.0
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
ports:
- "18080:18080"
volumes:
- ./config/nifi-registry/conf:/opt/nifi-registry/nifi-registry-0.3.0/conf
- ./config/nifi-registry/flow_storage:/opt/nifi-registry/nifi-registry-0.3.0/flow_storage
- ./config/nifi-registry/database/:/opt/nifi-registry/nifi-registry-0.3.0/database
screenshot
(sorry, can't comment yet, so I'm popping an answer)
Your log file says '/opt/nifi/nifi-current/logs/nifi-app.log' can't be open. Could it be a problem with your configuration file ?
I have two docker-compose.yml files in separate folders.
I'd like to run the two of them in the same command, in order for the services from both to be able to talk to each other.
However, when I go to the lowest common path ancestor and try to run docker-compose with both files, here is what happens:
$ docker-compose -f ./api-folder/docker-compose.yml -f ./front-folder/docker-compose.yml up -d
ERROR: build path /projects/front-folder/api either does not exist, is not accessible, or is not a valid URL.
$ docker-compose -f ./front-folder/docker-compose.yml -f ./api-folder/docker-compose.yml up -d
ERROR: build path /projects/api-folder/app either does not exist, is not accessible, or is not a valid URL.
Here are the two docker-compose.yml files:
/projects/front-folder/docker-compose.yml
version: '2'
services:
app:
restart: always
build: ./app
environment:
NODE_ENV: 'dev'
ports:
- "4400:4400"
volumes:
- ./app:/usr/src/app
nginx:
restart: always
build: ./nginx
volumes:
- ./logs:/usr/local/var/log/nginx
links:
- app
ports:
- "80:80"
/projects/api-folder/docker-compose.yml
version: '2'
services:
api:
restart: always
build: ./api
expose:
- "4600"
volumes:
- ./api:/usr/src/app
- ./logs:/logs
nginx:
restart: always
build: ./nginx
volumes:
- ./logs:/usr/local/var/log/nginx
links:
- api
ports:
- "81:80"
networks:
- hackerz
And the directory structure:
- /projects
- /front-folder
- /app
Dockerfile
- /nginx
Dockerfile
docker-compose.yml
- /api-folder
- /api
Dockerfile
- /nginx
Dockerfile
docker-compose.yml
I'm guessing the problem is with the build paths, but what I don't understand is:
Why Docker insists on searching build: ./api in /front-folder or the other way around?
How to circumvent this problem and be able to run both files together?
DOCKERFILE
Alternate Dockerfile.
Compose uses an alternate file to build with. A build path must also be specified.
service3:
build:
context: .
dockerfile: Dockerfile-alternate
docker compose build giving custom file
This isn't how compose works (by design). See my comment here: https://github.com/docker/compose/issues/3530#issuecomment-222490501.