Docker Community Forums

Share and learn in the Docker community.

Basic question on container stack


(Matt3224) #1


Sorry if this is a basic question im new to docker. I would like to know how to go about recreating my server environment, which is as follows:

CentOS 7
MariaDB 10
Im not sure if i get these all separate and install them or if i need a specific premade setup.

Any help or hand holding would be much appreciated!


(Menzo) #2

Hi @matt3224,

Awesome that you’re getting started with Docker. But I don’t think that it’s the best solution for what you want to achieve. CPanel is a really big and heavy framework that often takes a complete VPS to install. Why do you want to use Docker for this?

Docker can be used to run applications in a isolated environment. Docker containers don’t have the overhead of a virtual machine because they use cgroups and namespaces but share the same kernel.
When you’re developing a application you often have dependencies, and use various different processes. Docker helps decoupling and isolating these processes into containers. Making it easy to scale horizontally and reuse them.

Containers should be considered ephemeral. They aren’t persistent, and you should be able to just destroy a container and run a new one with very little configuration. If you have persistent data like uploads or a database, you use volumes. You can link a volume to a container so data written into that volume isn’t lost when you destroy the container. Because cPanel is like a monolith of tools, configs, websites, logs you can’t use volumes to seperate data from code.

I think it would be wiser to just get a clean VPS/Virtual Machine and run a clean install of cPanel in that. My guess is that it will also be more stable.

(Menzo) #3

But if you really want to use Docker for this, I would advice you look at this image to get started

(Nathan Le Claire) #4

You can run cPanel in a container just like any other Linux process :wink:

@matt3224, my recommendation would be to look into using Docker Compose for this. It might be a bit overwhelming at first but will pay off once you get the hang of it. There are some similar functionalities in the new 1.12 swarm stuff (i.e., boot a stack based on a file) but they are still experimental. Compose is the old stalwart.

(Matt3224) #5


Thanks for that. In my day-to-day I typically am working with wordpress sites, so for me to work with these I need to be able to have phpmyadmin and php etc.

I thought perhaps mirroring the setup of the server might be ideal as, what better place to test and build websites but locally on my machine in a replica environment.

I just need to know to what extent to use docker based on those requirements really.

(Matt3224) #6

Hey Nathan,

Thanks i’ll check it out

(Menzo) #7

Ah alright. I thought because you were using WHM you were planning to run some form of hosting company.

To start developing wordpress websites locally you’d need the following:

  1. Docker
  2. Docker Compose
  3. Wordpress container ( webserver & source code ) image
  4. Mysql container ( mysql server ) image

Like I explained in my previous post, docker has images and containers. Images are immutable and form the basis for your containers. For wordpress and mysql there are ‘official’ base images available that are maintained by the vendor and docker.

Using docker pull you can download these images so you can run them later.

 docker pull wordpress:4.6
 docker pull mysql:5.7

The wordpress image contains apache and php 5.6 by default, so you don’t have to worry about installing that manually.

Because you want to run a wordpress container and a database container in the same time, you can use docker compose. Docker compose reads a config file (docker-compose.yml) that contains instructions about what containers the run and how to run them.

To start your project, create a directory somewhere on your machine and cd into that directory using your terminal. Use nano or any other text editor, and create a file called docker-compose.yml. Add the following content:

version: '2'


    image: wordpress:4.6
      - 8080:80
      - db
      - db
      - "./wordpress:/var/www/html"
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_PASSWORD: wordpress

    image: mysql:5.7
    restart: always
      - "./.data/db:/var/lib/mysql"
      MYSQL_ROOT_PASSWORD: wordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

In this compose file there are two services defined, the database service and the wordpress service. These will become your containers. To simplify things a bit each service has it’s own volume, instead of separate data volume containers.

To start your containers all you need to do is run the command:

docker-compose up -d

To check if the containers are running you use:

docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
6537574425bf        wordpress:4.6       "/ apach"   8 minutes ago       Up 3 seconds>80/tcp   wordpress_wordpress_1
62b84298eaa5        mysql:5.7           ""   8 minutes ago       Up 4 seconds        3306/tcp               wordpress_db_1

You can open op your browser and go to http://localhost:8080 to see your wordpress website. Any changes you make to the wordpress directory on your host system are directly available in your container.

Hope this helps you getting set up. :slight_smile:

(Matt3224) #8

Thanks! Much appreciated