0

With docker compose file version 3 I can't seem to figure out how to create a data only container for my mariadb container.

Can anyone please suggest how to do it? Here is my current compose file:

  mariadb:
    image: mariadb:dev
    restart: always
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 1
      MYSQL_DATABASE: db
      MYSQL_USER: db_user
      MYSQL_PASSWORD: 1234
    build:
      context: mariadb
    volumes:
      - ./mariadb/db_data:/var/lib/mysql
  - ./mariadb/tools:/app/tools
container_name: mariadb
command: /app/tools/mariadb-start.sh mysqld

Basically, I would like to replace /mariadb/db_data mounted from host volume with a data only container that is used by my mariadb container.

Thanks!

3
  • Please consider a named volume rather than a data only container. Data containers have a lot of downsides, particularly losing all your data when you purge non-running containers. – BMitch Dec 15 '17 at 16:55
  • Hi @BMitch I ended up using named volumes indeed. However I don't see any real drawback of using data only containers, considering it is not possible for someone to purge non running containers in my case. Currently I am comparing performance of both, so this will be my reasoning when choosing what to use. – Radoslav Stefanov Dec 18 '17 at 8:46
  • 2
    Data containers are not supported in swarm mode, do not allow you to mount the volume in a different location in different containers, and use the same volume infrastructure under the covers so there should be no performance decrease. – BMitch Dec 18 '17 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.