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,
Related
My Nginx in docker-compose.yml:
...
nginx:
image: nginx:1.19.2-alpine
restart: always
hostname: nginx
ports:
- "9000:9000"
- "9001:9001"
depends_on:
- minio
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
container_name: nginx
...
I use docker compose up -d in terminal and it works fine.
However, when I use docker compose up -d in Jenkins container, it failed to create Nginx container with this error:
ERROR: for nginx Cannot start service nginx: failed to create shim: OCI runtime create failed:
container_linux.go:380: starting container process caused: process_linux.go:545:
container init caused: rootfs_linux.go:75: mounting
"/var/jenkins_home/workspace/workspace/nginx.conf" to rootfs at "/etc/nginx/nginx.conf" caused:
mount through procfd: 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
Does the error mean Docker want to mount the file inside Jenkins's volume so there's no nginx.conf to mount?
How can I mount my nginx.conf to my Nginx container?
Thanks in advance.
It looks you're executing docker-compose up from a location such your relative path ./nginx.conf is not correct.
This error is typical when docker-compose cannot find source to mount bind-volume.
Assure you're in the correct docker-compose context or try with absolute path instead of ./nginx.conf
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 having trouble with a volume in my docker-compose.yml.
docker-compose.yml:
version: "3.3"
services:
prometheus:
image: prom/prometheus:latest
container_name: pg_provi_promentheus
volumes:
- ${PWD}/resources/config/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- pg_provi_prometheus_data:/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
# - "-storage.local.path=/prometheus"
ports:
- "9090:9090"
node-exporter:
image: prom/node-exporter:latest
container_name: pg_provi_node_exporter
ports:
- "9100:9100"
grafana:
image: grafana/grafana:latest
container_name: pg_provi_grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_AUTH_ANONYMOUS_ENABLED=true
depends_on:
- prometheus
volumes:
- ${PWD}/resources/config/grafana/provisioning:/etc/grafana/provisioning:ro
- pg_provi_grafana_data:/var/lib/grafana
ports:
- "3000:3000"
volumes:
pg_provi_prometheus_data:
pg_provi_grafana_data:
I constantly get this error message on startup:
[INFO] starting containers
Creating network "pg_provi_default" with the default driver
Creating volume "pg_provi_pg_provi_prometheus_data" with default driver
Creating volume "pg_provi_pg_provi_grafana_data" with default driver
Creating pg_provi_promentheus ... error
Creating pg_provi_node_exporter ... done
ERROR: for pg_provi_promentheus Cannot start service prometheus: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/mnt/c/Entwicklung/home/_workspace/workspace/provinzial-prometheus-grafana/src/main/localhost/pg_provi/resources/config/prometheus.yml\\\" to rootfs \\\"/var/lib/docker/overlay2/643795a7aff240086c1d48371fd7ded76a52d70a53299b01a253c25a529ec0e5/merged\\\" at \\\"/var/lib/docker/overlay2/643795a7aff240086c1d48371fd7ded76a52d70a53299b01a253c25a529ec0e5/merged/etc/prometheus/prometheus.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
ERROR: for prometheus Cannot start service prometheus: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/mnt/c/Entwicklung/home/_workspace/workspace/provinzial-prometheus-grafana/src/main/localhost/pg_provi/resources/config/prometheus.yml\\\" to rootfs \\\"/var/lib/docker/overlay2/643795a7aff240086c1d48371fd7ded76a52d70a53299b01a253c25a529ec0e5/merged\\\" at \\\"/var/lib/docker/overlay2/643795a7aff240086c1d48371fd7ded76a52d70a53299b01a253c25a529ec0e5/merged/etc/prometheus/prometheus.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
ERROR: Encountered errors while bringing up the project.
Same docker-compose.yml on linux works perfectly fine. I don't get why I cannot mount my prometheus.yml into my container.
Startup and shutdown is straight forward via docker-compose up -d and docker-compose down -v.
Anyone got an idea? Thanks guys.
I am pretty noob in docker containerand docker compose.
I pulled in docker compose https://github.com/codeniko/pihole-coredns-tls-docker/blob/master/docker-compose.yml
I wanted to create entry point so I can enter container.
for which I made below changes
coredns_upstream:
image: "coredns/coredns"
tty: true
stdin_open: true
volumes:
- "./coredns/:/etc/coredns/"
command: -conf /etc/coredns/coreconfig-up
restart: unless-stopped
container_name: coredns_up
entrypoint: /bin/bash
networks:
coredns:
ipv4_address: 172.10.10.100
I added these changes:
tty: true
stdin_open: true
to be able to enter,
that didnt worked so I added
entrypoint: /bin/bash
that throws error when try to run container, docker compose up
ERROR: for coredns_upstream Cannot start service coredns_upstream: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown
ERROR: Encountered errors while bringing up the project.
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.