How to start apache2 automatically in a ubuntu docker container?

后端 未结 3 1031
情歌与酒
情歌与酒 2020-12-05 05:05

I am trying to create a Dockerfile that will start apache automatically. Nothing has worked. But If I log into the container and run service apache2 start it wo

3条回答
  •  星月不相逢
    2020-12-05 05:21

    My project was slightly different where I installed a bunch of other stuff, but the apache start portion matched above. Once I built this image and used it, my server started fine.

    FROM ubuntu:latest
    
    #install all the tools you might want to use in your container
    RUN apt-get update
    RUN apt-get install curl -y
    RUN apt-get install vim -y
    #the following ARG turns off the questions normally asked for location and timezone for Apache
    ARG DEBIAN_FRONTEND=noninteractive
    RUN apt-get install apache2 -y
    
    #change working directory to root of apache webhost
    WORKDIR var/www/html
    
    #copy your files, if you want to copy all use COPY . .
    COPY index.html index.html
    
    #now start the server
    CMD ["apachectl", "-D", "FOREGROUND"]
    

提交回复
热议问题