I am trying to use docker-compose to mount a single volume from a folder in the root directory of my project in order to distribute a configuration file to a series of redis master/slaves and sentinels.
My redis services look like this
# Redis redis-master/slave configurations
redis-master:
container_name: "redis-master"
image: redis/redis-stack:7.0.2-RC3
networks:
- redis
- api
command:
- "redis-server /etc/master.conf"
volumes:
- ./redis/clustering/redis-master/master.conf:/etc/master.conf
- ./redis_data/redis-master/:/data/
redis-slave-0:
container_name: "redis-slave-0"
image: redis/redis-stack:7.0.2-RC3
networks:
- redis
- api
command:
- "redis-server /etc/slave.conf"
volumes:
- ./redis/clustering/redis-slave/slave.conf:/etc/slave.conf
- ./redis_data/redis-slave-0/:/data/
redis-slave-1:
container_name: "redis-slave-1"
image: redis/redis-stack:7.0.2-RC3
networks:
- redis
- api
command:
- "redis-server /etc/slave.conf"
volumes:
- ./redis/clustering/redis-slave/slave.conf:/etc/slave.conf
- ./redis_data/redis-slave-1/:/data/
And my docker-compose.yml is located in the same directory as redis with the below structure
redis
├── clustering
│ ├── redis-master
│ │ └── master.conf
│ ├── redis-slave
│ │ └── slave.conf
│ └── sentinel
│ └── sentinel.conf
└── redis-reference.conf
4 directories, 4 files
When I try to build the project however I am getting this error for each service.
Creating redis-slave-0 ...
Creating redis-master ...
Creating postgres ... done
Creating redis-slave-1 ... error
Creating redis-master ... error
Creating redis-slave-0 ... error
Creating api ... done
Creating nginx ...
ERROR: for redis-master Cannot start service redis-master: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "redis-server /etc/master.conf": stat redis-server /etc/master.conf: no such file or directory: unknown
ERROR: for redis-slave-0 Cannot start service redis-slave-0: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "redis-server /etc/slave.conf": stat redis-server /etc/slave.conf: no such file or direc
Creating nginx ... done
ERROR: for redis-slave-1 Cannot start service redis-slave-1: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "redis-server /etc/slave.conf": stat redis-server /etc/slave.conf: no such file or directory: unknown
ERROR: for redis-master Cannot start service redis-master: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "redis-server /etc/master.conf": stat redis-server /etc/master.conf: no such file or directory: unknown
ERROR: for redis-slave-0 Cannot start service redis-slave-0: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "redis-server /etc/slave.conf": stat redis-server /etc/slave.conf: no such file or directory: unknown
ERROR: Encountered errors while bringing up the project.
The conf file is not being mapped.
Any idea what I'm missing to map this local folder with the relevant file to my services?
Related
The docker-compose file looks like this:
version: '2'
services:
portainer_agent:
image: portainer/agent:latest
container_name: portainer_agent
restart: unless-stopped
ports:
- 9001:9001
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
environment:
AGENT_CLUSTER_ADDR: tasks.agent
and it's giving this error:
Creating portainer_agent ... error
ERROR: for portainer_agent Cannot start service portainer_agent: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "./agent": stat ./agent: no such file or directory: unknown
I tried to find if anyone had this error on the internet and I couldn't find it anywhere.
so here i am i just created an account here.
i really don't know where to start, this error is from inside the container.
Any I missing something simple here. But Im trying to mount a host file to the container via docker-compose. My docker-compose.yml is:
version: '3.2'
services:
myapp_poller:
restart: unless-stopped
image: &myappImage netenglabs/myapp:0.13.0
container_name: myapp_poller
command: -D /myapp/inventory.yml -k
stdin_open: true
tty: true
volumes:
- "parquet-db:/myapp/parquet"
- "./config/inventory.yml:/myapp/inventory.yml"
- "./config/myapp-cfg.yml:/root/.myapp/myapp-cfg.yml"
entrypoint:
- sq-poller
If I go into ./config and run docker-compose up -d I get:
ERROR: for myapp_poller Cannot start service myapp_poller: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: rootfs_linux.go:60: mounting "/run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/Ubuntu-20.04/cc227aed2745c686a488b2a5b99142480733c23c6aa9f72f7d7cb77b4506cee2" to rootfs at "/var/lib/docker/overlay2/8b2cfc582829f784a1a918ba17ef667d2d4c4291b9c0d6655f6f813da486e333/merged/root/.myapp/myapp-cfg.yml" caused: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Thanks,
I am trying to get a nextcloud + mariadb + nginx docker-compose up and running locally, but I am stuck when it comes to the nginx.conf file. I am following this guide at the base-fpm section. Here is the docker-compose.yml file, what I ran in my CLI and the error i got:
version: '2'
volumes:
nextcloud:
db:
services:
db:
image: mariadb
restart: always
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=mypw
- MYSQL_PASSWORD=mypw
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
app:
image: nextcloud:fpm
restart: always
links:
- db
volumes:
- nextcloud:/var/www/html
environment:
- MYSQL_PASSWORD=mypw
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_HOST=db
web:
image: nginx
restart: always
ports:
- 8080:80
links:
- app
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
volumes_from:
- app
$ docker-compose up
Creating network "nextcloud_default" with the default driver
Creating volume "nextcloud_nextcloud" with default driver
Creating volume "nextcloud_db" with default driver
Creating nextcloud_db_1 ... done
Creating nextcloud_app_1 ... done
Creating nextcloud_web_1 ... error
ERROR: for nextcloud_web_1 Cannot start service web: OCI runtime create failed:
container_linux.go:370: starting container process caused: process_linux.go:459: container init
caused: rootfs_linux.go:59: mounting "/home/nowak/docker/nextcloud/nginx.conf" to rootfs at
"/var/lib/docker/overlay2/4869db7f0302ec8b7e5f4328b861e64627daa78728d443913052cecd1cd095a9/merge
d/etc/nginx/nginx.conf" caused: not a directory: unknown: Are you trying to mount a directory
onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:370:
starting container process caused: process_linux.go:459: container init caused:
rootfs_linux.go:59: mounting "/home/nowak/docker/nextcloud/nginx.conf" to rootfs at
"/var/lib/docker/overlay2/4869db7f0302ec8b7e5f4328b861e64627daa78728d443913052cecd1cd095a9/merge
d/etc/nginx/nginx.conf" caused: not a directory: unknown: Are you trying to mount a directory
onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
Do I need to create a nginx.conf file and place it in my work directory?
The guide does mention this:
The configuration for nginx is stored in the configuration file nginx.conf, that is mounted into the container. An example can be found in the examples section here.
But when I follow that link, I can't seem to find any example of nginx.conf files.
Looks like other people are also searching for the file, so I'll add the link from my comment to the right file here:
https://github.com/nextcloud/docker/blob/master/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/nginx.conf
I'm trying to use wait-for-it in my docker-compose.yaml to wait for mysql to be ready before creating services that are dependent on it. This is my docker-compose.yaml:
version: '3.5'
services:
mysql:
image: mysql:5.6
ports:
- "3307:3306"
networks:
- integration-tests
environment:
- MYSQL_DATABASE=mydb
- MYSQL_USER=root
- MYSQL_ROOT_PASSWORD=mypassword
entrypoint: ./wait-for-it.sh mysql:3306
networks:
integration-tests:
name: integration-tests
I get this error when trying to run this with docker-compose:
Starting integration-tests_mysql_1 ... error
ERROR: for integration-tests_mysql_1 Cannot start service mysql: OCI
runtime create failed: container_linux.go:348: starting container
process caused "exec: \"./wait-for-it.sh\": stat ./wait-for-it.sh: no
such file or directory": unknown
ERROR: for mysql Cannot start service mysql: OCI runtime create
failed: container_linux.go:348: starting container process caused
"exec: \"./wait-for-it.sh\": stat ./wait-for-it.sh: no such file or
directory": unknown ERROR: Encountered errors while bringing up the
project.
The wait-for-it.sh script is there on the same level as my docker-compose.yaml file so I don't understand why it's not being found.
Your issue here is that you're trying to execute something that is not part of your image. You're telling docker to create a container from mysql:5.6, which doesn't contain wait-for-it.sh, and then you're telling it to start the container by launching wait-for-it.sh.
I would recommend that you create your own image containing the following:
#Dockerfile
FROM mysql:5.6
COPY wait-for-it.sh /wait-for-it.sh
RUN chmod +x /wait-for-it.sh
Then you would replace mysql:5.6 with your image and you should be able to execute wait-for-it.sh. I would also execute it through a command instead of an entrypoint as such:
#docker-compose.yml
...
mysql:
image: yourmysql:5.6
command: bash -c "/wait-for-it.sh -t 0 mysql:3306"
...
Where -t 0 will wait for mysql without a timeout.
You can control services startup order by using the docker depends_on option.
I have a Dockerfile which I can successfully build an image from:
FROM iron/go:dev
RUN mkdir /app
COPY src/main/main.go /app/.
# Set an env var that matches your github repo name, replace treeder/dockergo here with your repo name
ENV SRC_DIR=/app
# Add the source code:
ADD . $SRC_DIR
# Build it:
RUN go get goji.io
RUN go get gopkg.in/mgo.v2
RUN cd $SRC_DIR; go build -o main
ENTRYPOINT ["/app/main"]
However, when I attempt to build the following docker-compose.yml file:
version: "3.3"
services:
api:
build: ./api
expose:
- '8080'
container_name: 'api'
ports:
- "8082:8080"
depends_on:
- db
networks:
- api-net
db:
build: ./db
expose:
- '27017'
container_name: 'mongo'
ports:
- "27017:27017"
networks:
- api-net
networks:
api-net:
driver: bridge
I get:
Removing api mongo is up-to-date Recreating
532e3cf66460_carsupermarket_api_1 ... error
ERROR: for 532e3cf66460_carsupermarket_api_1 Cannot start service
api: OCI runtime create failed: container_linux.go:348: starting
container process caused "exec: \"/GO/src/main\": stat /GO/src/main:
no such file or directory": unknown
ERROR: for api Cannot start service api: OCI runtime create failed:
container_linux.go:348: starting container process caused "exec:
\"/GO/src/main\": stat /GO/src/main: no such file or directory":
unknown ERROR: Encountered errors while bringing up the project.
I suspect that docker-compose is introducing some nuance when it comes to directory build paths, however, I'm at a loss as to why my image is building from the docker file when using docker build ., but failing when I try to incorporate this into docker-compose.
Can someone point me in the right direction as to what I am doing wrong?
I've upgraded to the latest version of Docker CE (18.03.1-ce, build 9ee9f40) and this appears to have resolved the issue.