6

I wanted to make a Dockerfile with multiple images to run in one container.

What is the best method to go about this? Below is a list of what I wanted to run in a single container. I have not have any luck with making a Dockerfile with all of these included.

  • MySQL Server
  • RabbitMQ
  • Java8
  • Node.js
  • Xvfb
  • Firefox
  • Chrome

This is what I have so far, can I get a few tips

FROM stackbrew/ubuntu:12.04
MAINTAINER 
# Update the repository sources list #RUN apt-get update  
# My SQL Server ############### 
RUN apt-get 
update -qq && apt-get 
install -y mysql-server-5.5 
ADD my.cnf /etc/mysql/conf.d/my.cnf 
RUN chmod 664 /etc/mysql/conf.d/my.cnf
ADD run /usr/local/bin/run 
RUN chmod +x /usr/local/bin/run  V
OLUME ["/var/lib/mysql"] 
EXPOSE 3306
CMD ["/usr/local/bin/run"] 
dfarrell07
  • 2,872
  • 2
  • 21
  • 26
user3633313
  • 71
  • 1
  • 2
  • 5
  • 1
    Please show what you have tried so far. That will help people answer your question better and provides a better learning experience for you. – Sidney Gijzen May 13 '14 at 16:24

2 Answers2

7

You cannot have "multiple images to run in one container", that wouldn't make sense.

But you can write a Dockerfile to create an image that will install all the services you mentionned. Example (Ubuntu/Debian distribution) :

[...header...]
FROM stackbrew/ubuntu:12.04 #or use ubuntu-upstart:12.04
MAINTAINER BPetkov  

# Update the repository sources list
RUN apt-get update -qq 

# Mysql
RUN apt-get install -y mysql-server-5.5  
ADD my.cnf /etc/mysql/conf.d/my.cnf 
RUN chmod 664 /etc/mysql/conf.d/my.cnf 
ADD run /usr/local/bin/run 
RUN chmod +x /usr/local/bin/run  

# Other stuff
RUN apt-get -y install rabbitmq
RUN apt-get -y install nodejs
[...]
VOLUME ["/var/lib/mysql"] 
EXPOSE 3306 
EXPOSE .......
CMD ["/sbin/init"]

Then you would have to get all of them started automatically when the container starts.

You can use a process manager such as supervisord (Docker documentation here).

Alternatively, you could use a regular init system, check this base image : ubuntu-upstart. This one would allow you to only have to install the packages in your Dockerfile and get them started automatically without any effort, by specifying /sbin/init as EntryPoint or CMD in your Dockerfile.

mbarthelemy
  • 12,465
  • 4
  • 41
  • 43
  • this is what I had so far `code FROM stackbrew/ubuntu:12.04 MAINTAINER BPetkov # Update the repository sources list #RUN apt-get update # My SQL Server ############### RUN apt-get update -qq && apt-get install -y mysql-server-5.5 ADD my.cnf /etc/mysql/conf.d/my.cnf RUN chmod 664 /etc/mysql/conf.d/my.cnf ADD run /usr/local/bin/run RUN chmod +x /usr/local/bin/run VOLUME ["/var/lib/mysql"] EXPOSE 3306 CMD ["/usr/local/bin/run"] ` – user3633313 May 13 '14 at 17:25
  • Thanks for the help, I still cant really figure out how to do this, the dockerfile will not build. – user3633313 May 13 '14 at 18:22
2

The feature you're looking for is Docker Compose.

jasonslyvia
  • 2,529
  • 1
  • 24
  • 33
  • 1
    Compose creates multiple container with 1 - 1 images which is not the same. We can communicate with each containers as well but it wont help in scal . Can you kubernetes or swarn to mange it – Aniketh Saha Apr 14 '19 at 09:20