Created by Kaushal Kishore
Email : [email protected]
Website : http://www.kaushalkishore.com
Step 1 : Clone the Docker-Nginx-Drupal.git
Command: git clone https://github.com/kaushalkishorejaiswal/Docker-Nginx-Drupal.git
Step 2 : Change the directory to the clone folder
Command: cd Docker-Nginx-Drupal
Step 3 : Create the Docker Image
Command: sudo docker build -t ##NAME_OF_YOUR_DOCKER_IMAGE## .
Note : a). This command will be fired where the DockerFile will be placed b). ##NAME_OF_YOUR_DOCKER_IMAGE## : Replace it with your image name c). . : (.) Symbols shows that your Dockerfile is available on the same directory where you are running the command.
Step 4 : Create an Drupal Installed Container from the image Command Syntax: sudo docker run --name [container name] -p [port to access (New Port):port exposed(original port)] -i -t [image name]
Command: sudo docker run --name ##NAME_OF_YOUR_DOCKER_CONTAINER## -d -p 8082:80 -p3307:3306 ##NAME_OF_YOUR_DOCKER_IMAGE##
Step 5 : Now you can access your Drupal container from your web browser.
Command: http://127.0.0.1:8082/
Step 6 : You can access your MySQL using the below command.
Command: mysql -uroot -proot -h172.17.42.1 -P3037
Important Notes
-
You can get the IP of the container using the command
- docker inspect ##Container ID##
-
To get the Container ID. Use the below command
- docker ps -a
- You can also access the Nginx using the container IP
- Read more details of MySQL Click Here
- docker images : To list all the images of your docker
- docker ps : To list all the runing containers
- docker kill ##CONTAINER_NAME## : To kill the runing container
- docker rm ##CONTAINER_NAME## : To delete the container from the system.
- docker inspect ##CONTAINER_NAME## : To get all the information about the container.
- docker logs ##CONTAINER_NAME## : To get the logs of the container.
- docker ps -a: To get the listing of all the containers.
Command Syntax: sudo docker run --name ##NAME_OF_YOUR_DOCKER_CONTAINER## -d -p 8082:80 -v ##HOSTED_VOLUME_LOCATION##:##CONTAINER_VOLUME_LOCATION## ##YOUR_IMAGE_NAME##
Command Example: sudo docker run --name nginx_ins -d -p 8082:80 -v /var/www/kaushal:/var/www nginx_kaushal
Read more details of Nginx and PHP Click Here
To view the Files of your container: # find ID of your running container: docker ps # create image (snapshot) from container filesystem docker commit 12345678904b5 mysnapshot # explore this filesystem using bash (for example) docker run -t -i mysnapshot /bin/bash
Other Drupal Important Notes:
- You can change the credential of the MySQL in docker file, after setting the (MYSQL_USER,MYSQL_PASS) variables
- You can also change the Drupal database name, after setting the (Drupal_DBNAME)
- The hostname will be prefixed with the port during the installation of the Drupal
- Docker-Centos-Nginx : https://github.com/kaushalkishorejaiswal/Docker-Centos-Nginx
- Docker-Centos-Nginx-PHP : https://github.com/kaushalkishorejaiswal/Docker-Centos-Nginx-PHP
- Docker-MySQL : https://github.com/kaushalkishorejaiswal/Docker-MySQL
- Docker-LAMP : https://github.com/kaushalkishorejaiswal/Docker-LAMP
Access/Modify the files inside the containers :
- Step 1 : Install the nsenter: docker run -v /usr/local/bin:/target jpetazzo/nsenter
- Step 2 : Figure out the PID of the container you want to enter:PID=$(docker inspect --format {{.State.Pid}} )
- Step 3 : Then enter inside the container: nsenter --target $PID --mount --uts --ipc --net --pid