I have the following folder structure:
scripts/
--constraints.cypher
docker-compose.yml
This is my docker-compose.yml:
services:
app-config-db:
image: neo4j:latest
container_name: app-config-db
ports:
- "7474:7474"
- "7473:7473"
- "7687:7687"
volumes:
- ./scripts:/var/lib/neo4j/scripts
environment:
- NEO4J_AUTH=neo4j/test123!
command:
- cypher-shell -u neo4j -p test123! --file /var/lib/neo4j/scripts/constraints.cypher
But when I run docker-compose up I get the following error:
error: exec: "cypher-shell -u neo4j -p test123! --file /var/lib/neo4j/scripts/constraints.cypher": stat cypher-shell -u neo4j -p test123! --file /var/lib/neo4j/scripts/constraints.cypher: no such file or directory
To me, it seems like the .scripts directory is not mounting correctly into my docker container, but everything seems in order. What am I doing wrong?
The scripts directory gets mounted correctly. The problem here is that you are specifying the command in an array form so docker searches for the executable file "cypher-shell -u neo4j -p test123! --file /var/lib/neo4j/scripts/constraints.cypher" which is obviously not found. You can either specify the command as a string
services:
app-config-db:
image: neo4j:latest
container_name: app-config-db
ports:
- "7474:7474"
- "7473:7473"
- "7687:7687"
volumes:
- ./scripts:/var/lib/neo4j/scripts
environment:
- NEO4J_AUTH=neo4j/test123!
command: cypher-shell -u neo4j -p test123! --file /var/lib/neo4j/scripts/constraints.cypher
Or split all the options up:
services:
app-config-db:
image: neo4j:latest
container_name: app-config-db
ports:
- "7474:7474"
- "7473:7473"
- "7687:7687"
volumes:
- ./scripts:/var/lib/neo4j/scripts
environment:
- NEO4J_AUTH=neo4j/test123!
command:
- cypher-shell
- -u
- neo4j
- -p
- test123!
- --file
- /var/lib/neo4j/scripts/constraints.cypher
This is similar to the CMD instruction in the Dockerfile. You can find more info in the compose file spec and the documentation for CMD.
Related
due to hardware problem, I had to replace my small home server with a new one.
Several self-hosted services with Docker were running on the server for which I tried to backup the volumes following the instructions on the official Docker website and those present in this YouTube video and in this cheat-sheet. Now, following the same documentation, I am trying to restore the backups but without success. The first one I'm trying for is a stack for Nginx Proxy Manager built with Docker compose with this docker-compose.yaml file:
version: "3.6"
services:
app:
image: jc21/nginx-proxy-manager:latest
restart: always
ports:
- "80:80"
- "443:443"
- "81:81"
environment:
DB_MYSQL_HOST: "db"
DB_MYSQL_PORT: 3306
DB_MYSQL_NAME: "db_name"
DB_MYSQL_USER: "db_user"
DB_MYSQL_PASSWORD: "db_password"
volumes:
- data:/data
- ./letsencrypt:/etc/letsencrypt
depends_on:
- db
db:
image: jc21/mariadb-aria:latest
restart: always
environment:
MYSQL_DATABASE: "db_name"
MYSQL_ROOT_PASSWORD: "root_password"
MYSQL_USER: "db_user"
MYSQL_PASSWORD: "db_password"
volumes:
- db:/var/lib/mysql
volumes:
db:
data:
After starting the stack with docker compose up -d command I'm trying to restore db and data volumes with:
docker run --rm --volumes-from nginx-proxy-manager-db-1 -v $(pwd):/backup ubuntu bash -c "cd / && tar xvf /backup/nginx-proxy-manager_db_20220717-082200.tar --strip 1"
docker run --rm --volumes-from nginx-proxy-manager-app-1 -v $(pwd):/backup ubuntu bash -c "cd / && tar xvf /backup/nginx-proxy-manager_data_20220717-082200.tar --strip 1"
What's wrong?
This question already has answers here:
docker: executable file not found in $PATH
(14 answers)
Closed 1 year ago.
I am new to docker. I am trying to containerise my Go application using docker-compose.
Technology used
Golang, Docker 20.10.8 and Air (for live reloading).
My Dockerfile looks like this.
FROM base as dev
WORKDIR /opt/app/api
RUN apk update
RUN apk add git gcc musl-dev
RUN apk add curl
RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
# RUN go get
# RUN go mod tidy
CMD ["air"]
My docker-compose.yml is this.
version: "3.9"
services:
app:
build:
dockerfile: Dockerfile.local
context: .
target: dev
container_name: 'server'
volumes:
- .:/opt/app/api
env_file:
- .env
ports:
- "8080:8080"
restart:
always
depends_on:
- db
- rabbitmq
db:
image: postgres:13-alpine
volumes:
- data:/var/lib/postgresql/data
container_name: 'postgres'
ports:
- 5432:5432
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD: postgres
rabbitmq:
image: rabbitmq:3-management-alpine
container_name: 'rabbitmq'
ports:
- 5672:5672
- 15672:15672
volumes:
- rabbitmq:/var/lib/rabbitmq
- rabbitmq-log:/var/log/rabbitmq
migrate: &basemigrate
profiles: ["tools"]
image: migrate/migrate
entrypoint: "migrate -database postgresql://thursday:postgres#db/postgres?sslmode=disable -path /tmp/migrations"
command: up
depends_on:
- db
volumes:
- ./migrations:/tmp/migrations
create-migration:
<<: *basemigrate
entrypoint: migrate create -dir /tmp/migrations -ext sql
command: ""
depends_on:
- db
down-migration:
<<: *basemigrate
entrypoint: migrate -database postgresql://thursday:postgres#db/postgres?sslmode=disable -path /tmp/migrations
command: down
depends_on:
- db
volumes:
data:
rabbitmq:
rabbitmq-log:
On running command sudo docker-compose up -d I am getting the following error
Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "air": executable file not found in $PATH: unknown
As mentioned in "docker: executable file not found in $PATH":
When you use the exec format for a command (in your case: CMD ["air"], a JSON array with double quotes) it will be executed without a shell.
This means that most environment variables will not be present.
CMD air should work, provided:
air is an executable (chmod 755)
air was cross-compiled to Linux (unless your host running docker is already Linux)
I'm trying to figure out why I can find a certificate file in a volume using:
docker run -v ~/.aspnet/https:/https:ro -p 80:80 -p 443:433 -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -e ASPNETCORE_Kestrel__Certificates__Default__Password=<MY PASSWORD HERE> housesearchwebsite
but not using:
docker-compose -f docker-compose.custom.yml up
with a docker-compose.custom.yml that looks like this: (sensitive information removed)
version: '3.4'
services:
housesearchwebsite:
image: housesearchwebsite
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
- ConnectionString=host=db;port=5432;database=<DATABASENAME>;username=<DBUSERNAME>password=<MY DB PASSWORD>
- ASPNETCORE_Kestrel__Certificates__Default__Password=<MY PASSWORD HERE>
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
ports:
- "80"
- "443"
volumes:
- ${HOME}/.aspnet/https:/https:ro
- images_volume:/var/lib/housesearch/images
networks:
- dev-net
volumes:
images_volume:
networks:
dev-net:
name: dev-net
I have some C# code that checks, first thing, if there is a aspnetapp.pfx file in the ASPNETCORE_Kestrel__Certificates__Default__Path path, but it is only found if I run the docker run command, and is not found if I use the docker-compose command.
Not sure why it started working randomly, but an issue I can clearly flag which might have been the reason for your error is that you are not mapping the ports properly in your docker-compose.yml.
Ports should be defined as:
ports:
- "80:80"
- "443:443"
Where the mapping would be in HOST:CONTAINER format.
Docs here
I am attempting to use the docker-compose.yml from the Rails example on the Docker site. This is a Windows (WSL2/Ubuntu/Docker Desktop) machine, so any files created in the docker container are owned by root. I am trying to pass my user id and group id as args, but I can't figure out a syntax that will let me:
version: "3.9"
services:
db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password
web:
build:
context: .
args:
- USER_ID=$(id -u)
- GROUP_ID=$(id -g)
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/myapp
ports:
- "3000:3000"
depends_on:
- db
I try i setup a Shopware Docker Container for development. I setup a Dockerfile for the Shopware initialize process but every time i run the build process shopware return this error message:
mysql -u 'root' -p'root' -h 'dbs' --port='3306' -e "DROP DATABASE IF EXISTS `shopware6dev`"
ERROR 2005 (HY000): Unknown MySQL server host 'dbs' (-2)
i think docker setup the default network after all build processes are done but i need to connect before all containers are ready. The depends_on option brings nothing. I hope anyone have a idea to solve this problem.
This is my docker-compose file:
version: '3'
services:
shopwaredev:
build:
context: ./docker/web
dockerfile: Dockerfile
volumes:
- ./log:/var/log/apache2
environment:
- VIRTUAL_HOST=shopware6dev.test,www.shopware6dev.test
- HTTPS_METHOD=noredirect
restart: on-failure:10
depends_on:
- dbs
adminer:
image: adminer
restart: on-failure:10
ports:
- 8080:8080
dbs:
image: "mysql:5.7"
volumes:
- ./mysql57:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=shopware6dev
restart: on-failure:10
nginx-proxy:
image: solution360/nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./ssl:/etc/nginx/certs
restart: on-failure:10
and this is my dockerfile for web shopwaredev container:
FROM solution360/apache24-php74-shopware6
WORKDIR /var/www/html
RUN rm index.html
RUN git clone https://github.com/shopware/development.git .
RUN cp .psh.yaml.dist .psh.yaml
RUN sed -i 's|DB_USER: "app"|DB_USER: "root"|g' .psh.yaml
RUN sed -i 's|DB_PASSWORD: "app"|DB_PASSWORD: "root"|g' .psh.yaml
RUN sed -i 's|DB_HOST: "mysql"|DB_HOST: "dbs"|g' .psh.yaml
RUN sed -i 's|DB_NAME: "shopware"|DB_NAME: "shopware6dev"|g' .psh.yaml
RUN sed -i 's|APP_URL: "http://localhost:8000"|APP_URL: "http://shopware6dev.test"|g' .psh.yaml
RUN ./psh.phar install