I use gitlab runners in docker.
It uses our own php image and mysql:5.7 image. It worked before, but now we can see this error when CI job is started:
Running with gitlab-runner 10.4.0 (857480b6)
on gitlab-runner-2 (00929f5e)
Using Docker executor with image registry.blahblah.work/infra/docker-base/php ...
Starting service mysql:5.7 ...
Pulling docker image mysql:5.7 ...
Using docker image mysql:5.7 ID=sha256:f008d8ff927dc527c5a57251b45cead7c9259c16a6a93c144f397eaafc103d36 for mysql service...
Waiting for services to be up and running...
*** WARNING: Service runner-00929f5e-project-4-concurrent-0-mysql-0 probably didn't start properly.
Error response from daemon: Cannot link to a non running container: /runner-00929f5e-project-4-concurrent-0-mysql-0 AS /runner-00929f5e-project-4-concurrent-0-mysql-0-wait-for-service/runner-00929f5e-project-4-concurrent-0-mysql-0
2018-02-13T08:49:03.752410664Z
2018-02-13T08:49:03.752468595Z ERROR: mysqld failed while attempting to check config
2018-02-13T08:49:03.752476292Z command was: "mysqld --verbose --help"
2018-02-13T08:49:03.752481759Z
2018-02-13T08:49:03.752486693Z mysqld: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 13 - Permission denied)
2018-02-13T08:49:03.752491885Z mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
Variables are set:
variables:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: password
What should I do to debug and fix this issue?
you need to change your docker compose file, you should add privileged: true mine looks like :
mysql:
build: ./DockerFiles/Mysql
ports:
- ${LOCAL_PHP_IP}:${MYSQL_PORT}:3306
privileged: true
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- /opt/mysql_data:/var/lib/mysql
Related
I'm trying to run a MYSQL container for my project using docker-compose.
When I use the following command, everything works fine:
docker run --name mysql-db -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 -d mysql:latest
But when I built this docker-compose file:
version: '3.8'
services:
mysql-db:
container_name: mysql-db
image: mysql:latest
environment:
- MYSQL_DATABASE='crm'
- MYSQL_ROOT_PASSWORD='password'
expose:
- "3306"
ports:
- "3306:3306"
The command:
docker-compose up --build
I got this message error:
mysql-db | '/var/lib/mysql/mysql.sock' ->
'/var/run/mysqld/mysqld.sock' mysql-db | Warning: Unable to
load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
mysql-db | Warning: Unable to load
'/usr/share/zoneinfo/leapseconds' as time zone. Skipping it. mysql-db
| Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time
zone. Skipping it. mysql-db | Warning: Unable to load
'/usr/share/zoneinfo/zone.tab' as time zone. Skipping it. mysql-db
| Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time
zone. Skipping it. mysql-db | ERROR 1064 (42000) at line 5: You
have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '''' at
line 1 mysql-db exited with code 1
I also notice that there is this log right here says that I didn't set the MYSQL_ROOT_PASSWORD although I've already declared that
mysql-db | 2023-01-10T07:29:03.521464Z 6 [Warning] [MY-010453]
[Server] root#localhost is created with an empty password ! Please
consider switching off the --initialize-insecure option.
I'm extremely new to docker so hope you guys can help me.
I tried to reproduce with your compose file locally on my machine and it resulted into same error.
Only solution for this problem currently lies in the link shared by #SelVazi. We would need to build your custom mysql image and then use that to create mysql container.
Here is an example
Create a Dockerfile
I picked mysql image with tag 8 as I am running on Mac M1.
FROM mysql:8.0.31-debian
RUN apt-get update \
&& apt-get install --no-install-recommends -y tzdata \
&& apt-get clean \
&& rm -r /var/lib/apt/lists/*
Create Docker Compose file
version: '3.8'
services:
mysql-local:
build: .
image: mysql-local:latest
ports:
- "3307:3307"
container_name: mysql-local
# I am running on Mac M1 Apple Silicon, You might not need it.
platform: linux/x86_64
mysql-db:
container_name: mysql-db
image: mysql-local:latest
depends_on:
- mysql-local
environment:
- MYSQL_DATABASE='crm'
- MYSQL_ROOT_PASSWORD='password'
expose:
- "3306"
ports:
- "3306:3306"
Run compose file
docker-compose -f mysql-compose.yaml up --build
I try to import my existing backup.sql.gz in mysql using docker. this is my docker-compose.yml
mysql:
image: mysql:5.7
container_name: ${APP_NAME}-mysql
restart: unless-stopped
volumes:
- ./database:/var/lib/mysql
- ./mysqldumps/backup.sql.gz:/docker-entrypoint-initdb.d
environment:
MYSQL_DATABASE: ${DB_NAME}
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
when I try to run docker-compose up i got an error:
ERROR: for 52bf24fa5ad1_project Cannot start service mysql: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused "rootfs_linux.go:58: mounting \"project/mysqldumps/backup.sql\" to rootfs \"/var/lib/docker/overlay2/be2a6a81a405ab94e956086e578ecec2a98207ef53c8f85aaaf053d79d3c183a/merged\" ...
How can I fix it? thanks.
This indicates that the mount path of the volume is not existing.
I'm new to docker and I'm following this guide to setup my mac (the guide is for linux but is not the point) for a PHP dev env with docker-compose.
The guide is quite good and everything seems to work correctly, there is just a part that doesn't seem to work.
If you go to Step 9 — Creating a User for MySQL, I'm running docker-compose up and I have these errors so I can't access the db container.
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
db | 2020-04-16T18:22:19.603226Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
db | 2020-04-16T18:22:19.603246Z 0 [ERROR] [MY-010119] [Server] Aborting
If I remove the - ./mysql/my.cnf:/etc/mysql/my.cnf from the volumes everything seem to work but then for some reason my laravel db is not created.
these command is not supposed to already create a DB?
environment:
MYSQL_DATABASE: laravel
MYSQL_ROOT_PASSWORD: root
another question is where the data is stored?
db:
...
volumes:
- dbdata:/var/lib/mysql
...
#Volumes
volumes:
dbdata:
driver: local
how it works that driver local and what is the location of it?
I just found out that the tutorial uses a wrong path, the correct path is:
- ./mysql/my.cnf:/etc/my.cnf
and not:
- ./mysql/my.cnf:/etc/mysql/my.cnf
docker-compose.yml
version: '3.7'
services:
db:
image: mysql:8.0.21
container_name: dbweb
restart: always
environment:
MYSQL_ROOT_PASSWORD: 'deivypassword'
TZ: America/New_York
ports:
# : < MySQL Port running inside container>
- '3306:3306'
# Where our data will be persisted
volumes:
- dbweb2:/var/lib/mysql
- ./my.cnf:/etc/mysql/my.cnf
Names our volume
volumes:
dbweb2:
I am currently beginning experiments with docker-compse. I've created a minimal Flask + MySQL webservice which works perfectly fine without Docker. Now I would like to see how I can make deployment easy with Docker.
My docker-compose.yml looks like this:
version: '3'
services:
web:
build: .
command: app.py
ports:
- "8082:8082"
volumes:
- .:/code
links:
- db
hostname: myappserver
environment:
- MYSQL_ROOT_PASSWORD=p#ssw0rd123
- MYSQL_DATABASE=flask_db
- MYSQL_HOST=db
- MYSQL_PORT=3306
db:
image: mysql
ports:
- "3307:3306"
environment:
- MYSQL_ROOT_PASSWORD=p#ssw0rd123
- MYSQL_DATABASE=flask_db
- MYSQL_HOST=mysqlserver
When I run sudo docker-compose up --build I get
web_1 | sqlalchemy.exc.ProgrammingError: (mysql.connector.errors.ProgrammingError) 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist [SQL: "SHOW VARIABLES LIKE 'sql_mode'"]
db_1 | 2017-07-21T22:27:26.553761Z 3 [Note] Aborted connection 3 to db: 'flask_db' user: 'root' host: '172.18.0.3' (Got an error reading communication packets)
What is the problem and how do I fix it?
(The complete project is here: https://github.com/MartinThoma/flask_mysql_dockerized - it's really tiny)
No duplicate of
1: I know if this was on my machine, that I could fix it with mysql_upgrade -u root -p --force and /etc/init.d/mysql start. But the point of using docker compose is to make it really simple to start a web service. One command. If I have to tell the user to login into the container, run those commands, restart the other container.. then I could simply ask him to install it on the main system / run docker containers manually.
So here is what I did to fix it, where I hope that this is possible to be done less manually:
Start the containers:
# docker-comopse up
Find the container ID of the mysql image:
# docker container ls
Enter the container
# sudo docker exec -it 4f7d3f0763ad bash
Upgrade
# mysql_upgrade -u root -p --force
Exit the container, then restart
# docker-compose up
Initialize the database:
# cd /docker-entrypoint-initdb.d/
# mysql -h localhost -u root -p
mysql> source flask_db.sql;
You need to add database to your mysql service:
volumes:
- ./flask_db.sql:/docker-entrypoint-initdb.d/flask_db.sql
Tip: It is recommended to use smaller images so that your image has only required basic components and free from extra non-essential stuff.
I have a problem with Mysql Docker which exits when I run my docker-compose up command.
Here is my docker-compose.yml file :
version: "2"
services:
web:
build: ./app
links:
- "db-mongo:db-mongo"
- "db-mysql:db-mysql"
ports:
- "443:3000"
volumes:
- "./app:/src"
- "/src/.sass-cache"
- "/src/node_modules"
- "/src/lib"
db-mongo:
build: ./mongo
ports:
- "27017:27017"
volumes:
- "./mongo/db:/data"
db-mysql:
image: mysql
ports:
- "3306:3306"
volumes:
- "./mysql/db:/var/lib/mysql"
- "./mysql/log:/var/log/mysql"
- "./mysql/conf.d:/etc/mysql/conf.d"
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: testt
Folders ./mysql/db and ./mysql/log are empty.
When I run docker-compose up, here the output :
db-mysql_1 | Initializing database
server_db-mysql_1 exited with code 1
When I run docker ps -a :
0a5a7a643f18 mysql "docker-entrypoint.sh" 8 minutes ago Exited (1) 7 minutes ago server_db-mysql_1
The strange thing is if I run docker run -d --name=new-mysql -p 3306:3306 -v /var/www/server/mysql/db:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password mysql it works...
And here the output of docker logs 97c -f:
Initializing database
Database initialized
MySQL init process in progress...
Warning: Unable to load '/usr/share/zoneinfo/Factory' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/posix/Factory' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/right/Factory' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
MySQL init process done. Ready for start up.
Why does my docker-compose can't keep alive my mysql docker ? I must missing something... Help ! Thanks
EDIT : It appears it is my conf.d folder which is making some problems, because when I remove volume - "./mysql/conf.d:/etc/mysql/conf.d", server_db-mysql keeps alive.
Here is the mysql/conf.d/my.cnf file content :
[mysqld]
general_log_file = /var/log/mysql/mysql.log
general_log = 1
Why does that file is crashing the mysql ?
It's a permission issue when mounting /var/log/mysql in your custom config file.
Please reference this issue #docker-mysql-146 for the solution:
The owner and group of the /var/log/mysql directory has to be as expected by mysql. Ensure that, execute:
docker exec mysql chown mysql:root /var/log/mysql