Create directory on local system
# mkdir -p /root/docker-task/php7.2
# cd /root/docker-task/php7.2
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
#Add PHP repository
RUN apt-get install -y software-properties-common \
&& apt-add-repository ppa:ondrej/php
RUN apt-get update
#Setup Time zone
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Kolkata
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#Install PHP package
RUN apt-get -y install php7.2 php7.2-common
#change working directory to root of apache webhost
WORKDIR /var/www/html
#copy your files, if you want to copy all use COPY . .
COPY info.php info.php
#now start the server
CMD ["apachectl", "-D", "FOREGROUND"]Run command to create image from Dockerfile
Run command to build docker image
# docker build -t php7.2:v1 .
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 apacheweb1 bash
Access php page
http://docker_container_ip/info.php
0 comments:
Post a Comment