Create dockerfile for apache webserver

Create directory on local system

# mkdir -p /root/docker-task/apache2
# cd  /root/docker-task/apache2

Create Dockerfile for apache web-server for Ubuntu platform 

# vim Dockerfile

FROM ubuntu:18.04
RUN apt-get update && apt-get install -y apache2 vim
RUN  apt-get install  -y openssh-server

#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"]

Run command to create image from Dockerfile
# docker build .

Run command to check docker images
# docker images

Run command to create docker container
docker run -it --name containername image_id

Run command to check running docker container
# docker ps

Run command to check all running and stopped container
# docker ps -a

Login to docker container
docker exec -it apachecon1 bash

Share on Google Plus

About Penguin Technology

I am a passionate cloud and DevOps professional specializing in Linux and open-source solutions. Through this blog, I share my knowledge and experience with the community, offering tips and insights on cloud technologies and DevOps practices.
    Blogger Comment

0 comments:

Post a Comment