Docker Community Forums

Share and learn in the Docker community.

Docker-compose Create database


#1

I am using Docker Engine Version: 18.09.0.

The sever is built from XXX_server(ubuntu18.04, python3.7) and mysql:8.0
I installed the docker-compose file on several different computers and everything works fine.
But on Ubuntu version 16.04.2 LTS (Xenial Xerus), the database is not created.

Any idea why?

The docker-compose file:

version: “3”
services:
XXX_server:
image: XXX_server
command: python3 XXX-srv.py

db:
mysql:8.0
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: XXXX
MYSQL_DATABASE: database
volumes:
my-datavolume:/var/lib/mysql
volumes:
my-datavolume:


(Ovelindstrom) #2

Some issues with your docker-compose configuration. Image not defined correctly. The volumes takes an array. This works for me in a 16.04 LTS instance. However, it takes a lot of memory, so make sure that you have free memory on the instance when you start it.

version: '3.7'
  services:
    db:
      image: mysql:8.0
      command: --default-authentication-plugin=mysql_native_password
      restart: always
      environment:
        MYSQL_ROOT_PASSWORD: XXXX
        MYSQL_DATABASE: database
      volumes:
        - my-datavolume:/var/lib/mysql
  volumes:
    my-datavolume:`