0

I am new to Docker. I have these services (pm2 (backend), apache (UI and data-batches (php), GO services and Database (postgresql)) running in an application.

What is the best method to create a Docker image? My plan is to create a Docker image for each service (as data-batches as more hits) and link together in a single container/more container and load it in a single instance. Will this method work for me?

halfer
  • 19,824
  • 17
  • 99
  • 186
user3906723
  • 117
  • 2
  • 15
  • No, don't do that - that sounds like Docker-in-Docker for no good reason. Create a Docker image for each one, and then run them together using Docker Compose. – halfer May 11 '18 at 07:27
  • Thanks I will follow this method, Create a Docker image for each one, and then run them together using Docker Compose. – user3906723 May 11 '18 at 10:00

1 Answers1

0

you can define a docker-compose for your main service and add other services as dependencies to it. Refer to docker-compose for more details.

Sample docker-compose could be

web:
  image: example/my_web_app:latest
  links:
    - db
    - cache
  env:
    - CACHE_URL: redis:6379

db:
  image: postgres:latest

redis:
  image: redis:latest
  ports:
    - "6379:6379"

This ensures that redis and postgres are started before your Main service.

Hope this helps.

Community
  • 1
  • 1
krisnik
  • 1,406
  • 11
  • 18