-
we can search php and apache image on Docker Hub, we will use php:7.0-apache for this demo.
-
create Dockerfile and src/index.php as below
root@ubunu2004:~/docker_sample# tree . ├── Dockerfile └── src └── index.php 1 directory, 2 files root@ubunu2004:~/docker_sample# cat Dockerfile FROM php:7.0-apache COPY src/ /var/www/html EXPOSE 80 root@ubunu2004:~/docker_sample# cat src/index.php <?php echo "Hello World!";
-
build the container
docker build -t hello_world .
-
run the container
docker run -p 82:80 hello_world
then you can verify it on http://192.168.0.43:82/ -
if you want mapping the index.php to container, you can start it with
docker run -p 82:80 -v /root/docker_sample/src/:/var/www/html/ hello_world
now if you update index.php, you will get the change immediately on http://192.168.0.43:82/ -
you can push this image to Docker Hub
root@ubunu2004:~/docker_sample# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello_world latest dc8c649d4e8b 19 minutes ago 368MB
root@ubunu2004:~/docker_sample# docker run -it -d hello_world:latest
root@ubunu2004:~/docker_sample# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d2963444e718 hello_world:latest "docker-php-entrypoi…" 10 seconds ago Up 6 seconds 80/tcp laughing_williamson
root@ubunu2004:~/docker_sample# docker commit d2963444e718 zhuby1973/php:1
sha256:1f2007f4786c344c8007b574af6f71b7604431c6d6cce0e2091e6adf1a8c8621
root@ubunu2004:~/docker_sample# docker push zhuby1973/php:1
This paragraph is genuinely a nice one it helps new web visitors,
who are wishing for blogging.
It?s hard to come by experienced people for this topic, but you seem
like you know what you?re talking about! Thanks
Feel free to visit my site Jolt Alpha
Very good info. Lucky me I discovered your website by chance (stumbleupon).
I’ve book-marked it for later!