When I run docker-compose up with this docker-compose.yml.
version: '3'
services:
rundeck:
build:
context: ./
args:
RUNDECK_IMAGE: ${RUNDECK_IMAGE:-rundeck/rundeck:SNAPSHOT}
links:
- mysql
tty: true
environment:
RUNDECK_GRAILS_URL: http://localhost
RUNDECK_SERVER_FORWARDED: 'true'
RUNDECK_DATABASE_DRIVER: com.mysql.jdbc.Driver
RUNDECK_DATABASE_USERNAME: rundeck
RUNDECK_DATABASE_PASSWORD: rundeck
RUNDECK_DATABASE_URL: jdbc:mysql://mysql/rundeck?autoReconnect=true&useSSL=false
RUNDECK_PLUGIN_EXECUTIONFILESTORAGE_NAME: com.rundeck.rundeckpro.amazon-s3
RUNDECK_PLUGIN_EXECUTIONFILESTORAGE_S3_BUCKET: ${RUNDECK_PLUGIN_EXECUTIONFILESTORAGE_S3_BUCKET}
RUNDECK_PLUGIN_EXECUTIONFILESTORAGE_S3_REGION: ${RUNDECK_PLUGIN_EXECUTIONFILESTORAGE_S3_REGION}
RUNDECK_STORAGE_CONVERTER_1_CONFIG_PASSWORD: ${RUNDECK_STORAGE_PASSWORD}
RUNDECK_CONFIG_STORAGE_CONVERTER_1_CONFIG_PASSWORD: ${RUNDECK_STORAGE_PASSWORD}
volumes:
- data:/home/rundeck/server/data
- ${AWS_CREDENTIALS}:/home/rundeck/.aws/credentials
- ${RUNDECK_LICENSE_FILE:-/dev/null}:/home/rundeck/etc/rundeckpro-license.key
nginx:
image: nginx
links:
- rundeck
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- 80:80
mysql:
image: mysql:5.7
expose:
- 3306
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=rundeck
- MYSQL_USER=rundeck
- MYSQL_PASSWORD=rundeck
volumes:
- dbdata:/var/lib/mysql
volumes:
data:
dbdata:
I get the following error:
xxxx_mysql_1 is up-to-date
Creating xxxx_rundeck_1 ... error
ERROR: for xxxx_rundeck_1 Cannot create container for service rundeck: create .: volume name is too short, names should be at least two alphanumeric characters
ERROR: for rundeck Cannot create container for service rundeck: create .: volume name is too short, names should be at least two alphanumeric characters
ERROR: Encountered errors while bringing up the project.
I don't see a create . statement anywhere in the docker-compose.yml or the Dockerfile.
What am I missing?
You need to update the variable in env file. It is commented and hence adds null value to config.
https://github.com/rundeck/docker-zoo/blob/master/cloud/.env.dist#L3
Used in
https://github.com/rundeck/docker-zoo/blob/master/cloud/docker-compose.yml#L27
I got same issue and it resolved once i updated the env variables with value.
I once got this issue when the .env file contained
AWS_CREDENTIALS:foo
instead of
AWS_CREDENTIALS=foo
Related
Hello I want to publish the "index.php" from the local folder "C:\html\index.php" with docker-compose.yml
in localhost I get the typical apache html "It works". But I do not get the content of my local folder. What I am doing wrong?
here is my docker-compose file:
version: "3"
services:
# --- MySQL 5.7
#
mysql:
container_name: "dstack-mysql"
image: bitnami/mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_USER=admin
- MYSQL_PASSWORD=root
ports:
- '3306:3306'
php:
container_name: "dstack-php"
image: bitnami/php-fpm:8.1
# --- Apache 2.4
#
apache:
container_name: "dstack-apache"
image: bitnami/apache:2.4
ports:
- '80:8080'
- '443:8443'
depends_on:
- php
volumes:
- C:/html:/var/www/html
phpmyadmin:
container_name: "dstack-phpmyadmin"
image: bitnami/phpmyadmin:latest
depends_on:
- mysql
ports:
- '81:8080'
- '8143:8443'
environment:
- DATABASE_HOST=host.docker.internal
volumes:
dstack-mysql:
driver: local
Update:
volumes:
- ./html:/var/www/html
Doesn't works.
I want to have a web development docker environment where I edit in the folder C:\html\index_hello.html in my computer and I will see the changes in the browser localhost:8080, the changes I did. My expectation is that I write in the browser http://localhost:8080/index_hello.html. Did I something wrong? shall I edit other files e.g. apache.conf?
I would suggest avoiding hardcoding directories and using relative directories.
If you place your docker-compose into your C:/html folder and then change you volume to read:
volumes:
- .:/var/www/html
if you run the following:
cd C:/html
docker-compose up -d
you are telling docker-compose to use . meaning the current directory.
if you put the docker-compose.yml in the C:/ directory you can run change the volume to:
volumes:
- ./html:/var/www/html
then the docker compose command should remain the same.
I get the below error when I run docker-compose up, any pointers why I am getting this error
service "mysqldb-docker" refers to undefined volume mysqldb: invalid compose project
Also, is there a way to pass the $ENV value in CLI to docker-compose up , currently I have a ENV variable that specified dev, uat or prod that I use to specify the db name. Are there better alternatives to do this other than create a .env file explicitly for this
version: '3.8'
services:
mysqldb-docker:
image: '8.0.27'
restart: 'unless-stopped'
ports:
- "3309:3306"
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_PASSWORD=root
- MYSQL_DATABASE=reco-tracker-$ENV
volumes:
- mysqldb:/var/lib/mysql
reco-tracker-docker:
image: 'reco-tracker-docker:v1'
ports:
- "8083:8083"
environment:
- SPRING_DATASOURCE_USERNAME=root
- SPRING_DATASOURCE_PASSWORD=root
- SPRING_DATASOURCE_URL="jdbc:mysql://mysqldb-docker:3309/reco-tracker-$ENV"
depends_on: [mysqldb-docker]
You must define volumes at the top level like this:
version: '3.8'
services:
mysqldb-docker:
# ...
volumes:
- mysqldb:/var/lib/mysql
volumes:
mysqldb:
You can pass environment variables from your shell straight through to a service’s containers with the ‘environment’ key by not giving them a value
https://docs.docker.com/compose/environment-variables/#pass-environment-variables-to-containers
web:
environment:
- ENV
but from my tests you cant write $ENV in the compose file and expect it to read your env
for this you need to call docker-compose that way :
docker-compose run -e ENV web python console.py
see this : https://docs.docker.com/compose/environment-variables/#set-environment-variables-with-docker-compose-run
I have a dockerimage on a gitlab registry.
when I (after login on a target machine)
docker run -d -p 8081:8080/tcp gitlab.somedomain.com:5050/root/app
the laravel app is available and running and reachable. Things like php artisan config:clear are working. when I enter the container everything looks fine.
But I don't have any services running. So I had the idea to create a yml file to docker-compose run to set things up in docker-compose-gitlab.yml
version: '3'
services:
mysql:
image: mysql:5.7
container_name: my-mysql
environment:
- MYSQL_ROOT_PASSWORD=***
- MYSQL_DATABASE=dbname
- MYSQL_USER=username
- MYSQL_PASSWORD=***
volumes:
- ./data/mysql:/var/lib/mysql
ports:
- "3307:3306"
application:
image: gitlab.somedomain.com:5050/root/app:latest
build:
context: .
dockerfile: ./Dockerfile
container_name: my-app
ports:
- "8081:8080"
volumes:
- .:/application
env_file: .env.docker
working_dir: /application
depends_on:
- mysql
links:
- mysql
calling docker-compose --verbose -f docker-compose-gitlab.yml up shows me that the mysql service is created and working, the app seems also be creeated but then fails ... exiting with code 0 - no further message.
If I add commands in my yml like php artisan config:clear the error gets even unclearer for me: it says it cannot find artisan and it seems as if the command is executed outside the container ... exiting with code 1. (artisan is a helper and executed via php)
When I call the docker-compose with -d and then do docker ps I can only see mysql running but not the app.
When I use both strategies, the problem is, the two container do not share a common network and can so not work together.
What did I miss? Is this the wrong strategy?
The problem is, that I let a volume directive left over which overwrites my entier application with an empty directory.
You can just leave that out.
version: '3'
services:
mysql:
image: mysql:5.7
container_name: my-mysql
environment:
- MYSQL_ROOT_PASSWORD=***
- MYSQL_DATABASE=dbname
- MYSQL_USER=username
- MYSQL_PASSWORD=***
volumes:
- ./data/mysql:/var/lib/mysql
ports:
- "3307:3306"
application:
image: gitlab.somedomain.com:5050/root/app:latest
build:
context: .
dockerfile: ./Dockerfile
container_name: my-app
ports:
- "8081:8080"
## volumes:
## - .:/application ## this would overwrite the app
env_file: .env.docker
working_dir: /application
depends_on:
- mysql
links:
- mysql
You can debug the network of the containers listing the networks with docker network ls
then when the list is shown inspect the compose network with docker inspect <ComposeNetworkID>
Once you are shure that your services are not in the same network, remove your containers and recreate it again with docker-compose -f docker-compose-gitlab.yml up
If you notice they are in the same network try to use the container name instead localhost to reach each other, if it is the case.
I have a value in a Dockerfile called ${APP_NAME}. What is it? If this were bash scripting, I would assume it to be some sort of variable but it hasn't been assigned a value anywhere. Is it a command line argument? If so, how would I pass it in when I wanted to call docker-compose with it?
For reference, the Docker file looks like this:
version: '2'
services:
nginx:
container_name: ${APP_NAME}_nginx
hostname: nginx
build:
context: ./containers/nginx
dockerfile: Dockerfile
ports:
- "80:80"
- "443:443"
volumes:
- .:/app
links:
- phpfpm
networks:
- backend
phpfpm:
container_name: ${APP_NAME}_phpfpm
hostname: phpfpm
expose:
- "9000"
build:
context: ./containers/php-fpm
dockerfile: Dockerfile
working_dir: /app
volumes:
- .:/app
links:
- mysql
networks:
- backend
mysql:
container_name: ${APP_NAME}_mysql
hostname: mysql
build:
context: ./containers/mysql
dockerfile: Dockerfile
volumes:
- ./storage/mysql:/var/lib/mysql
- ${MYSQL_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d
environment:
- MYSQL_DATABASE=${DB_DATABASE}
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
ports:
- "33061:3306"
expose:
- "3306"
networks:
- backend
networks:
backend:
driver: "bridge"
And actually, I'm probably going to have a lot of questions about docker because I've never really used it before so a reference to Dockerfile syntax would be helpful.
This means that there is probably somewhere in your project .env file which contains variables necessary for docker compose. You can find more about it at the official docker compose docs. It says that you can set default values for environment variables using a .env file, which Compose automatically looks for. Values set in the shell environment override those set in the .env file. Try to find more here: https://docs.docker.com/compose/compose-file/#variable-substitution
In my Docker Instance, I created a volume called jokes. I'm trying to build out my service now with docker-compose up but I keep getting this error message:
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.db.volumes contains an invalid type, it should be an array
Here is my docker-compose.yml file:
version: '3.6'
services:
web:
build: .
command: puma
depends_on:
- db
environment:
DATABASE_URL: "postgres://postgres#db"
ports:
- "3000:3000"
volumes:
- "./:/app"
working_dir: /app
db:
image: "postgres:10.3-alpine"
volumes: "-jokes: /var/lib/postgresql/data"
volumes:
jokes: ~
How should I fix this?
How should I fix this?
As detailed in the official documentation you are required to give a list there (hence complaint about list), so move hyphen outside the quotes like so:
volumes:
- "jokes:/var/lib/postgresql/data"