After successfully installing WordPress in a docker container and pushing it in github repository, you can use it in other ubuntu server by following the steps
Step 1: Clone Repository using git clone command
Go to directory /var/www/html then paste the repository link. Her, I used a private repository and copy pasted it together with git clone command.
$ cd /var/www/html $ git clone https://github.com/nucleiotechnologies/wordpress-dockered.git
Step 2: Change credentials
Go to project directory then open docker-compose.yml file and change the following credentials for your own use.
$ cd wordpress-dockered $ sudo nano docker-compose.yml
Then you will see the following inside the file then change its credentials. You can also change the port if it is already in use or leave it as it is.
version: "3" services: #MySQL Database image my_database: image: mysql restart: always environment: MYSQL_ROOT_PASSWORD: my_password_1234789 MYSQL_DATABASE: my_wp_database MYSQL_USER: my_wp_user MYSQL_PASSWORD: my_wp_user_password volumes: - mysql:/var/lib/mysql #WordPress image based on Apache wordpress: depends_on: - my_database image: wordpress:latest restart: always ports: - "8000:80" environment: WORDPRESS_DB_HOST: my_database:3306 WORDPRESS_DB_USER: my_wp_user WORDPRESS_DB_PASSWORD: my_wp_user_password WORDPRESS_DB_NAME: my_wp_database volumes: ["./:/var/www/html"] volumes: mysql: {}
Press CTRL X + Y then hit ENTER to save changes.
Step 3: Run Docker Container
After applying changes to docker-compose.yml file, run docker by typing the command:
$ docker-compose up -d
Once it is running, you can now navigate to your browser and go to localhost:8000
localhost:8000
If it shows the WordPress installation site, you successfully deployed it.