Docker Community Forums

Share and learn in the Docker community.

Apache & Mysql Service Ubuntu Docker Conatiner

Hi everyone,

I’m very new at docker. I don’t know how to write a docker file. I have downloaded the Ubuntu20.04 official image from the docker hub. I want to create LAMP(Linux, Apache, Mysql, PHP7.4) for site hosting. I have run a container from that & inside that, I have installed & configured(Apache, MySQL, PHPMyAdmin, PHP7.4 version). And from that container, I have created an image. Till now everything works fine.
The real problem comes when I created a container from that image. The container is starting but apache2 & MySQL service is not starting. every time I have to go inside the container and need to start both services. I want, both services should be auto-started after booting the container.

Can anyone help me with this? After lots of googling, I found nothing.

The command I have used to lunch container

docker run -dit --name lamp-7.1 -p 80:80 -v /home/docker/ubuntu-docker:/var/www/html ubuntu-lamp-7.1

Thanks in advance!