1

I am new to Docker so and this is giving me a headache. I finish developing a site in Magento linking multiple images using docker-compose.yml.

Here is my docker-compose.yml

version: '3'
services:
  web:
    image: webdevops/php-apache-dev:7.1
    container_name: web
    restart: always
    user: application
    environment:
    - WEB_ALIAS_DOMAIN=local.domain.com
    - WEB_DOCUMENT_ROOT=/app/pub
    - PHP_DATE_TIMEZONE=EST
    - PHP_DISPLAY_ERRORS=1
    - PHP_MEMORY_LIMIT=2048M
    - PHP_MAX_EXECUTION_TIME=300
    - PHP_POST_MAX_SIZE=500M
    - PHP_UPLOAD_MAX_FILESIZE=1024M
    volumes:
    - "./:/app:cached"
    ports:
    - "80:80"
    - "443:443"
    - "32823:22"
    links:
    - mysql
  mysql:
    image: mariadb:10
    container_name: mysql
    restart: always
    ports:
    - "52000:3306"
    environment:
    - MYSQL_ROOT_PASSWORD=root
    - MYSQL_DATABASE=magento
    volumes:
    - db-data:/var/lib/mysql
  phpmyadmin:
    container_name: phpmyadmin
    restart: always
    image: phpmyadmin/phpmyadmin:latest
    environment:
    - MYSQL_ROOT_PASSWORD=root
    - PMA_USER=root
    - PMA_PASSWORD=root
    ports:
    - "8080:80"
    links:
    - mysql:db
    depends_on:
    - mysql
volumes:
  db-data:
    external: false

Then docker-compose up -d --build. I have 3 images and 3 containers running on my local machine.

I want to publish these image on hub.docker.com so anyone can download the image and get all the containers running.

Also is there a way to add a MySQL DB to the image, so anyone can have the same running website like I had on my local?

tk421
  • 5,775
  • 6
  • 23
  • 34

1 Answers1

1

Remember that the only thing you can publish on Docker Hub is Docker images; you can't publish containers, volumes, Docker Compose YAML files, or other artifacts. Since the YAML file is a fairly straightforward text file it's very common to publish that on GitHub, along with a README file explaining how to use it.

You don't need to push the phpmyadmin/phpmyadmin or mariadb images because those are standard Docker Hub images, so you only need to push your custom image. I would highly recommend removing the volumes: that mounts your local development tree over the image contents to validate that the image actually has what you expect.

Is there a way to add mysql DB to the image

No. The various standard Docker database images are built in a way that it is extremely difficult to build an image containing prepopulated data. Wordpress image with mysql data has some good discussion on the topic, and MySQL Docker container is not saving data to new image has some good analysis in the question proper.

David Maze
  • 130,717
  • 29
  • 175
  • 215