I want to run mysql on windows using docker container when i try use docker-compose up command on docker-compose file this the result.
> D:\dockerfiles>docker-compose up
db_1 | Initializing database
db_1 | 2018-10-08T09:00:29.024081Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
db_1 | 2018-10-08T09:00:29.024224Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
db_1 | 2018-10-08T09:00:29.024512Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1 | 2018-10-08T09:00:29.028590Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
db_1 | 2018-10-08T09:00:29.028673Z 0 [ERROR] Aborting
db_1 |
dockerfiles_db_1 exited with code 1
and this my docker-compose.yml
version: '3.7'
services:
db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: star
MYSQL_USER: user
MYSQL_PASSWORD: pass
update of docker compose file
version: '3.7'
services:
mysqldb:
image: mysql:5.7
container_name: mysql_con1
command: --default-authentication-plugin=mysql_native_password
command: --disable-partition-engine-check
restart: always
environment:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: star
MYSQL_USER: user
MYSQL_PASSWORD: pass
volumes:
- "./:/var/lib/mysql"
networks:
- samplenet
networks:
samplenet:
driver: nat
This happens if you run a foreground container (using docker run ), and then press Ctrl+C when the program is running. When this happens, the program will stop, and the container will exit. The container has been stopped using docker stop : You can manually stop a container using the docker stop command.
Common exit codes associated with docker containers are: Exit Code 0: Absence of an attached foreground process. Exit Code 1: Indicates failure due to application error.
There are some files in /var/lib/mysql
directory. Remove everything from this directory.
Or highly recommended, use volumes in docker-compose.yml
.
volumes:
- /my/own/datadir:/var/lib/mysql
Update: I tested with the following compose file, it worked fine without any errors.
version: '3.7'
services:
db:
image: mysql:5.7
restart: always
volumes:
- ./data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: star
MYSQL_USER: user
MYSQL_PASSWORD: pass
For those who ran the container using the docker run
command and added the --detach|-d
flag; Remove and rerun the container without the -d
flag.
This should provide the error message to why it fails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With