Wordpress Access denied for user root with MySQL container - docker

I'm trying to make MySQL instance available to other containers, I'm following this documentation mysql and this wordpress official documentation, I get this error
MySQL Connection Error: (1045) Access denied for user 'root'#'172.17.0.3' (using password: YES)
Code for MySQL instance
docker run -d --restart on-failure -v hatchery:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=Kerrigan \
-e MYSQL_DATABASE=zerglings --name spawning-pool mysql
Code for WordPress instance
docker run -d --name lair -p 8080:80 --link spawning-pool:mysql wordpress
How can I successfully link wordpress and mysql containers?

you need to pass in your database connection credentials via environment variables to wordpress:
docker run -d --name lair -p 8080:80 --link spawning-pool:mysql \
-e WORDPRESS_DB_HOST=mysql \
-e WORDPRESS_DB_NAME=zerglings \
-e WORDPRESS_DB_PASSWORD=zerglings wordpress

I have solved it by deleting everything and try starting it up again.
docker rm -v spawning-pool # -v Remove the volumes associated with the container
Remove the volume too
docker volume rm hatchery
Then I created the containers again
# create the volume
docker volume create hatchery
# MySQL instance
docker run -it -d --restart on-failure -v hatchery:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=Kerrigan \
-e MYSQL_DATABASE=zerglings --name spawning-pool mysql
# creating wordpress
docker run -d --name lair -p 8080:80 --link spawning-pool:mysql \
-e WORDPRESS_DB_HOST=mysql -e WORDPRESS_DB_NAME=zerglings
-e WORDPRESS_DB_PASSWORD=Kerrigan wordpress

Related

How to create multiple Debezium connectores for mysql database

I am tring to connect multiple Debezium connectores for a mysql database and my configurations are as follows.
sudo docker run -it --name zookeeper -p 2181:2181 -p 2888:2888 -p 3888:3888 debezium/zookeeper:1.5 &
sudo docker run -it --name kafka -p 9092:9092 --link zookeeper:zookeeper debezium/kafka:1.5 &
sudo docker run -it --name connect -p 8083:8083 -e GROUP_ID=1 -e CONFIG_STORAGE_TOPIC=my_connect_configs -e OFFSET_STORAGE_TOPIC=my_connect_offsets -e STATUS_STORAGE_TOPIC=my_connect_statuses --link zookeeper:zookeeper --link kafka:kafka debezium/connect:1.5 &
sudo docker run -it --name connect1 -p 8084:8084 -e GROUP_ID=1 -e CONFIG_STORAGE_TOPIC=my_connect_configs -e OFFSET_STORAGE_TOPIC=my_connect_offsets -e STATUS_STORAGE_TOPIC=my_connect_statuses --link zookeeper:zookeeper --link kafka:kafka debezium/connect:1.5 &
but when i tring to run second connector...following error occurred.
ERRO[0000] error waiting for container: context canceled
Can anyone help me with this please.
You're not running any connectors, only containers for workers.
One Kafka Connect worker can be used to submit more than one connector task via the HTTP server on port 8083
Regarding the commands shown, you do not need multiple containers unless you are trying to create a Connect worker cluster
In order to do so, they need the same topics and the same group id.
You'd also want -p 8084:8083 since you've not changed the server port. Also, rather than using &, you can do docker run -d, but using Docker Compose would make more sense here

Docker containers in read-only mode

still pretty new to docker and i could use some help. I am trying to setup some docker containers precisely the redash appplication. Here is my working code:
sudo docker network create redash_default
sudo docker container run --name redis --network redash_default -d redis:4.0-alpine
sudo docker container run --name postgres --network redash_default --env-file /opt/redash/env -v /opt/redash/postgres-data -d postgres:9.5.21-alpine
sudo docker container run --rm -p 5000:5000 -e REDASH_WEB_WORKERS=4 --name server --network redash_default --env-file env redash/redash:7.0.0.b18042 create_db
sudo docker container run -d --restart always -p 5000:5000 -e REDASH_WEB_WORKERS=4 --name server --network redash_default --env-file env redash/redash:7.0.0.b18042
sudo docker container run -d --restart always -e QUEUES=celery -e WORKERS_COUNT=1 --name scheduler --network redash_default --env-file env redash/redash:7.0.0.b18042
sudo docker container run -d --restart always -e QUEUES=scheduled_queries,schemas -e WORKERS_COUNT=1 --name scheduled_worker --network redash_default --env-file env redash/redash:7.0.0.b18042
sudo docker container run -d --restart always -e QUEUES=queries -e WORKERS_COUNT=2 --name adhoc_worker --network redash_default --env-file env redash/redash:7.0.0.b18042
sudo docker container run -d --restart always -p 80:80 --link server:redash --name nginx --network redash_default redash/nginx:latest
however i am only allowed to run the containers in read-only mode which is breaking the application. Only redis seemed to like the read-only mode so i thought about mounting an external persistent disk on the instance /dockervol/ where the apps can be given RW access but i cant seem to get that work either. here is something i have tried for example with nginx
docker container run -p 80:80 --mount type=bind,source=/dockervol/nginx,target=/etc/nginx – read-only --link server:redash --name nginx --network redash_default redash/nginx:latest
i get an error
nginx: [emerg] open() “/etc/nginx/nginx.conf” failed (2: No such file or directory)
My question is how do i get all the containers to work in read-only mode with a persistent volume without breaking the application.

I try to mount a created database from host, name mydb, onto mysql container here is what I’ve tried:

I try to mount a created database from host, name mydb, onto mysql container here is what I’ve tried:
sudo docker run -v mysql-data:/var/lib/mysql/mydb/ --name mysql_web -e MYSQL_ROOT_PASSWORD=12345 -p 3306:3306 -d mysql:5.7
root#ip-172-31-16-134:/var/lib/mysql# sudo docker run -v mysql-data:/var/lib/mysql/mydb/ --name mysql_web -e MYSQL_ROOT_PASSWORD=12345 -p 3306:3306 -d mysql:5.7
3c0a8eb588c0dd0d0b7b72a727912744f44e744e700de7efc64a0c4c1f651685
root#ip-172-31-16-134:/var/lib/mysql# docker exec -it mysql_web bash
Error response from daemon: Container 3c0a8eb588c0dd0d0b7b72a727912744f44e744e700de7efc64a0c4c1f651685 is not running
but it works when I change where to mount…
sudo docker run -v mysql-data:/var/lib/mydb/ --name mysql_web -e MYSQL_ROOT_PASSWORD=12345 -p 3306:3306 -d mysql:5.7
root#ip-172-31-16-134:/var/lib/mysql# sudo docker run -v mysql-data:/var/lib/mydb/ --name mysql_web -e MYSQL_ROOT_PASSWORD=12345 -p 3306:3306 -d mysql:5.7
06233eeb864c32ff16d6542e632a4da3ff6dfbd4a30fcc9aac8086dfc1245948
root#ip-172-31-16-134:/var/lib/mysql# docker exec -it mysql_web bash
root#06233eeb864c:/# cd /var/lib/mydb
root#06233eeb864c:/var/lib/mydb# exit
exit
seems It can’t mount onto specific folder and I don’t know why, I just want both databases, one from host, and the other from container, synced itself instead of loading dump.sql everytime when I start a new container.
any suggestion would help , thanks
This is known issue for the error you got [ERROR] --initialize specified but the data directory has files in it. Aborting.
What this error means is explained here.
Try few things like
Adding --ignore-db-dir=lost+found as mentioned here.
Providing exact path of data directory on host and mount on to container path at /var/lib/mysql like this docker run -v /path/to/mysql-data:/var/lib/mysql --name mysql_web -e MYSQL_ROOT_PASSWORD=12345 -p 3306:3306 -d mysql:5.7 as mentioned here.
Hope this helps.

How to set postgres password when creating odoo container?

I need some command to create odoo and postgres containers but using -e POSTGRES_PASSWORD_FILE=... like this:
docker run -p 5000:5432 -e POSTGRES_PASSWORD_FILE=... --name db postgres:9.6
docker run -tid -p 9000:8069 -v $path/addons:/mnt/extra-addons --name od --link db:db -t odoo:12
odoo image accepts a PASSWORD env
PASSWORD: The password of the postgres role with which Odoo will
connect. If you used a postgres container, set to the same value as
POSTGRES_PASSWORD. Defaults to odoo.
docker run -p 5000:5432 -e POSTGRES_PASSWORD_FILE=/run/secrets/postgres-passwd --name db postgres:9.6
# or
docker run -p 5000:5432 -e POSTGRES_PASSWORD=weak_pwd --name db postgres:9.6
docker run -tid -p 9000:8069 -e PASSWORD=weak_pwd -v $path/addons:/mnt/extra-addons --name od --link db:db -t odoo:12

docker mounted volume data getting wiped after restart the server

I am trying with docker. I ran kong docker Image and linked it with cassandra database which is mounted to the folder /data/api. but whenever I restart the server I am not able to see the mounted volume and all the data in the db lost.
here is the command which i am using
docker run -d --name kong-database -p 9042:9042 -v /data/api:/var/lib/cassandra cassandra:2.2
after i run db docker image I am running kong
docker run --privileged -d --name kong --link kong-database:kong-database -e "KONG_DATABASE=cassandra" -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" -e
"KONG_PG_HOST=kong-database" -p 80:8000 -p 443:8443 -p 7001:7001 -p 7946:7946 -p 7946:7946/udp kong
my kong entries are there mounted to the folder /data/api. but when I restarted my servercouldn't see the folder /data/api
because of this reason I am stuck at my work. can anyone help me on this?
Thanks in advance,

Resources