env-file and MariaDB in docker-compose - docker

I'm trying to set up nextcloud on a Raspberry Pi 3B+ with MariaDB, roughly following this example:
https://github.com/nextcloud/docker/blob/master/.examples/docker-compose/with-nginx-proxy/mariadb/apache/docker-compose.yml
My compose file looks like this:
version: '3'
services:
db:
image: mariadb
env_file:
- pi.env
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- ${BASE_PATH}/db:/var/lib/mysql
nextcloud:
image: nextcloud:apache
env_file:
- pi.env
restart: always
ports:
- 80:80
- 443:443
volumes:
- ${BASE_PATH}/www:/var/www
depends_on:
- db
environment:
- MYSQL_HOST=db
Then there is the pi.env file:
MYSQL_PASSWORD=secure-password
MYSQL_ROOT_PASSWORD=even-more-secure.password
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
BASE_PATH=/tmp
After running docker-compose up from the directory the yaml and the env file are sitting in, the two containers start up fine. Alas, the database connection can not be established because the db-container only accepts a blank password (popping up a shell in the container and running mysql -u nextcloud without handing in a password gives me database access). Still, the $MYSQL_ROOT_PASSWORD environment variable can be correctly echoed from the container.
If I start a mariadb-image alone with docker run -e MYSQL_ROOT_PASSWORD=secure-password, everything behaves as expected.
Can someone point me to my mistake?

I finally cured my setup some time ago. Sadly, I can not reconstruct what did the trick anymore (and my git commit messages were not as clear to my future self as I hoped they would be :D).
But it appears to me that exclusively declaring the environment variables for the database password in the pi.env file instead of the docker-compose.yaml did the trick.
My docker-compose.yaml:
services:
db:
image: jsurf/rpi-mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
restart: always
volumes:
- db:/var/lib/mysql
env_file:
- pi.env
nextcloud:
image: nextcloud:apache
restart: always
container_name: nextcloud
volumes:
- www:/var/www/html
environment:
- VIRTUAL_HOST=${VIRTUAL_HOST}
- LETSENCRYPT_HOST=${VIRTUAL_HOST}
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
- MYSQL_HOST=db
- NEXTCLOUD_TRUSTED_DOMAINS=${VIRTUAL_HOST}
- NEXTCLOUD_TRUSTED_DOMAINS=proxy
env_file:
- pi.env
depends_on:
- db
networks:
- proxy-tier
- default
pi.env:
MYSQL_PASSWORD=secure-password
MYSQL_ROOT_PASSWORD=even-more-secure.password
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
But thank you non the less #Zanndorin!

I know this is a super late answer but I just stumbled upon this while Googling something completely unrelated.
If I recall correctly you have to tell docker-compose to actually send the ENV variables to the docker by just declaring them in environment.
environment:
- MYSQL_HOST=db
- MYSQL_PASSWORD
- MYSQL_USER
I have never declared the .env-file in the docker-compose so maybe that already fixes that issue. I use it this way (I also have a .env file which I then sometimes override some values from).
Example from my developer MariaDB container:
environment:
- MYSQL_DATABASE=mydb
- MYSQL_USER=${DB_USER}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_ROOT_PASSWORD

Related

How to configure docker-compose.yml to use passbolt with docker-compose?

I use docker with WSL2 on a Debian VM and i'm trying to install passbolt.
I follow the steps on this guide : https://help.passbolt.com/hosting/install/ce/docker.html.
When i run docker-compose up, it's working and i can reach the database with telnet but it's impossible to reach the instance of passbolt with telnet and with my browser.
It's strange because the two containers: mariadb and passbolt are running.
This is my docker-compose.yml:
version: '3.4'
services:
db:
image: mariadb:10.3
env_file:
- env/mysql.env
volumes:
- database_volume:/var/lib/mysql
ports:
- "127.0.0.1:3306:3306"
passbolt:
image: passbolt/passbolt:latest-ce
#Alternatively you can use rootless:
#image: passbolt/passbolt:latest-ce-non-root
tty: true
container_name: passbolt
restart: always
depends_on:
- db
env_file:
- env/passbolt.env
volumes:
- gpg_volume:/etc/passbolt/gpg
- images_volume:/usr/share/php/passbolt/webroot/img/public
command: ["/usr/bin/wait-for.sh", "-t", "0", "db:3306", "--", "/docker-entrypoint.sh"]
ports:
- 80:80
- 443:443
#Alternatively for non-root images:
# - 80:8080
# - 443:4433
volumes:
database_volume:
gpg_volume:
images_volume:
If anybody can help me, thanks!
Your docker-compose file looks quite ordinary and I don't see any issues.
Can you please attach your passbolt.env and mysql.env (remove any important information ofcourse).
Also, the passbolt.conf (VirtualHost) might be useful.
Make sure that the DNS A record is valid and that you have no firewall blocks.
Error logs will be appreciated aswell.

Nextcloud in docker Exit Code 127

I want to start nextcloud and mariadb on docker with a compose file. If I use the following line, there's an error:
command: –-transaction-isolation=READ-COMMITTED --binlog-format=ROW
db_nextcloud exited with code 127
If I don't use this parameters, it works, but I think, this parameters are necessary?
Here the compose file:
version: "3"
services:
db_nextcloud:
container_name: db_nextcloud
image: linuxserver/mariadb:arm32v7-latest
restart: always
command: –-transaction-isolation=READ-COMMITTED --binlog-format=ROW
volumes:
- /var/lib/docker/volumes/mariadbnextcloud2:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=xxx
- MYSQL_PASSWORD=xxx
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
nextcloud:
container_name: nextcloud
image: nextcloud
restart: always
depends_on:
- db_nextcloud
ports:
- 8080:80
links:
- db_nextcloud
volumes:
- /var/lib/docker/volumes/nextcloud2:/var/www/html
environment:
- MYSQL_PASSWORD=q&zxTmQf
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_HOST=mariadbnextcloud
Are you sure that linuxserver's Dockerfile allows passing command line options for the mariadb-daemon? As far as I can see on a quick review those arguments are passed to the /init binary but not actively forwarded to the mariadbd. The original mariadb Dockerfile provides an ENTRYPOINT where you can easily pass parameters like this. All matches I could find with –-transaction-isolation=READ-COMMITTED --binlog-format=ROW are based on the original mariadb-image.
Additionally, the exit code 127 is used by bash to indicate a file-not-found error - but could also come from /init to indicate something completely different.

InfluxDB in Docker Bad gateway

I started setting up my Smart Home System in Docker with Openhab, mosquitto, Grafa etc. The Docker topic is still relatively new to me and I have not managed to connect InfluxDB with Grafana. Whenever I try, Influxdb: Bad Gateway appears. I did a lot of research on the Internet, but I couldn't find a solution that could help me. Maybe someone knows the problem and can help me.
Here is my docker-compose file:
influxdb:
image: influxdb:latest
container_name: influxdb
restart: always
ports:
- 8086:8086
environment:
- INFLUXDB_DB=telegraf
- INFLUXDB_USER=telegraf
- INFLUXDB_ADMIN_ENABLED=true
- INFLUXDB_ADMIN_USER=admin
- INFLUXDB_ADMIN_PASSWORD=Welcome1
volumes:
- influxdb:/var/lib/influxdb
grafana:
container_name: "grafana"
image: "grafana/grafana:latest"
restart: always
ports:
- 3000:3000
volumes:
- ./grafana:/var/lib/grafana
Grafana+InfluxDB datasource setup dialogue propose http://localhost:8086 as default for URL field. This is a suggestion to leave it like this, being grafana and influxdb indeed on the same host
And this results in the BAD Gateway error.
Problem is they are also two services inside docker and they should refer each other through the name of their docker compose sections so, in your case, like this
Regarding your volumes sections, the one in influxdb declaration probably should have been:
volumes:
- ./influxdb:/var/lib/influxdb
to map the container folder /var/lib/influxdb to the host folder ./influxdb, next to the ./grafana one but this is not related to the BAD Gateway issue.
volumes section was missing. Here is the working one.
version: '3'
services:
influxdb:
image: influxdb:latest
container_name: influxdb
restart: always
ports:
- 8086:8086
environment:
- INFLUXDB_DB=telegraf
- INFLUXDB_USER=telegraf
- INFLUXDB_ADMIN_ENABLED=true
- INFLUXDB_ADMIN_USER=admin
- INFLUXDB_ADMIN_PASSWORD=Welcome1
volumes:
- influxdb:/var/lib/influxdb
grafana:
container_name: "grafana"
image: "grafana/grafana:latest"
restart: always
ports:
- 3000:3000
volumes:
- grafana:/var/lib/grafana
volumes:
influxdb:
grafana:

Deploy existing Prestashop to server using Docker

I've created PrestaShop store on server. Is there any possible way to use docker for my store and migrate it into another server using docker? I know that I'll need docker-compose but to be honest I don't know what to do with files on current server.
Ok, so I deeped into problem and solution for ma quesstion is as below. What I did is pull original image from prestashop and copy there my files.
Next step was use mariadb image. I had backup.sql file exported from previous store phpmyadmin
version: '2'
services:
prestashop:
image: prestashop
ports:
- 80:80
links:
- mariadb:mariadb
depends_on:
- mariadb
volumes:
- ./src:/var/www/html
- ./src/modules:/var/www/html/modules
- ./src/themes:/var/www/html/themes
- ./src/override:/var/www/html/override
environment:
- PS_DEV_MODE=1
- DB_SERVER=mariadb
- DB_USER=root
- DB_PASSWD=root
- DB_NAME=prestashop
- PS_INSTALL_AUTO=0
mariadb:
image: mariadb
volumes:
- backup.sql:/docker-entrypoint-initdb.d
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=prestashop
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- mariadb
ports:
- 81:80
environment:
- PMA_HOST=mariadb
- PMA_USER=root
- PMA_PASSWORD=root
The biggest issue is IP in docker-machine. Keep in mind that if you are using docker toolbox you have IP 192.168.99.100 but in Docker for Windows your IP depends on localhost (or just type localhost).
You can use this docker-compose.yml :
version: "3"
services:
prestashop:
image: prestashop/prestashop
networks:
mycustomnetwork:
ports:
- 82:80
links:
- mariadb:mariadb
depends_on:
- mariadb
volumes:
- ./src:/var/www/html
- ./src/modules:/var/www/html/modules
- ./src/themes:/var/www/html/themes
- ./src/override:/var/www/html/override
environment:
- PS_DEV_MODE=1
- DB_SERVER=mariadb
- DB_USER=root
- DB_PASSWD=mycustompassword
- DB_NAME=prestashop
- PS_INSTALL_AUTO=0
mariadb:
image: mariadb
networks:
mycustomnetwork:
volumes:
- presta_db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=mycustompassword
- MYSQL_DATABASE=prestashop
phpmyadmin:
image: phpmyadmin/phpmyadmin
networks:
mycustomnetwork:
links:
- mariadb:mariadb
ports:
- 1235:80
depends_on:
- mariadb
environment:
- PMA_HOST=mariadb
- PMA_USER=root
- PMA_PASSWORD=mycustompassword
volumes:
presta_db:
networks:
mycustomnetwork:
external: true
Replace mycustomnetwork and mycustompassword
Then run docker-compose up
Web url : localhost:82
PHP MyAdmin url : localhost:1235
You can follow this tutorial to setup Prestashop in a Docker environment.
https://hub.docker.com/r/prestashop/prestashop/
You will need to add your current files to the Prestashop container and most likely import your database in a MySQL container. Docker-compose will be used to launch those containers together. Once this is done, you will be able to deploy the whole thing anywhere.
You should also include bridge network in your compose file, some examples might work from here https://runnable.com/docker/docker-compose-networking.
This way db can be configured to be accessed only by prestashop on local docker network without being exposed outside. Presta db can also be pointed to the name of the running image, in case your IP changes or something. All what you would leave running is port 80 on the app.

Why is drone.io keeping information of previous runs?

I want to delete all previous information of drone and make a completely new installation. So what I'm doing is this.
With this dockerfile:
version: '2'
services:
drone-server:
image: drone/drone:0.8
ports:
- 80:8000
- 9000
volumes:
- /var/lib/drone:/var/lib/drone/
restart: always
environment:
- DRONE_OPEN=true
- DRONE_HOST=http://drone-server:8000
- DRONE_GITEA=true
- DRONE_GITEA_URL=http://web:3000
- DRONE_SECRET=${DRONE_SECRET}
drone-agent:
image: drone/agent:0.8
command: agent
restart: always
depends_on:
- drone-server
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_SERVER=drone-server:9000
- DRONE_SECRET=${DRONE_SECRET}
web:
image: gitea/gitea:1.3.2
volumes:
- ./data:/data
ports:
- "3000:3000"
- "22:22"
depends_on:
- db
restart: always
db:
image: mariadb:10
restart: always
environment:
- MYSQL_ROOT_PASSWORD=changeme
- MYSQL_DATABASE=gitea
- MYSQL_USER=gitea
- MYSQL_PASSWORD=changeme
volumes:
- ./db/:/var/lib/mysql
I'm made a docker-compose up
Then to delete everything I made a docker-compose down. And make sure to delete every volume and every container manually. But when I do docker-compose up again the old information is still there. Why? Where is drone getting that information? I'm new with drone and docker so probably I'm doing something wrong because this does not make sense. Maybe I'm forgetting to delete something.
Can you help me with that?
Drone stores details about its runs in an SQLite db in /var/lib/drone by default, which you have mounted as a volume, so the stuff it saves in there is kept on your machine when you spin things down and passed back to the new containers when you create them.
If you want to completely reset everything you need to remove the files in your host machines /var/lib/drone folder too.

Resources