Easier working with the docker – warden, wordpress installation
In this article I will show you how to easily install WordPress with the docker with the warden tool. This tool makes it easier for us to work on our project environment, preparing many things for us. Therefore, someone who does not know the docker well can easily prepare the environment for a project using CLI warden.
This tool is only available for Linux and macOS, but unfortunately it is not supported on Windows.
To read about the topic of the docker read our previous article – Installation of WordPress and Docker with your own local domain
We install CLI warden on Linux Ubuntu
We will work on Linux Ubuntu 20.04.1 LTS. First we have to prepare our system and install the appropriate packages with docker and warden.
Use the command to install the docker:
sudo snap install docker
We can carry out warden installations using Homebrew or clone from a repository.
brew install davidalger/warden/warden
warden svc up
sudo mkdir /opt/warden
sudo chown $(whoami) /opt/warden
git clone -b master https://github.com/davidalger/warden.git /opt/warden
echo 'export PATH="/opt/warden/bin:$PATH"' >> ~/.bashrc
warden svc up
We create a WordPress project using warden and docker
Create a folder named example and go to it.
Inside the folder we start warden and establish our .env file using the commands:
warden svc up
After env-init we have to enter the name of our project: example, and then the project type: wordpress.
We compile our environment with functions:
warden env up -d --build
In order to be able to use the site correctly, you need to add a certificate using it:
warden sign-certificate example.test
Now we can go to the SSH of our project example.test
Once we are in shell of our site, we download the latest version of WordPress and unpack and remove the package:
tar xfz latest.tar.gz
mv wordpress/* ./
rm -f latest.tar.gz
We add our website to the /etc/hosts file.
Finally, in order to be able to connect through the browser to our site we need to add our site to the hosts file. Go to the main folder of our system and enter:
sudo nano /etc/hosts
We add a new line inside the file:
We can now connect to our site: https://example.test
We have received the WordPress configuration view
S WordPress installation
We move on to the installation of WordPress. We will need the data to connect to the database and the host. These are in the .env file in our project folder – example. Go to the project folder and type in:
There are values there:
Here we have our database name, user name and password under DB_DATABASE, DB_USERNAME, DB_PASSWORD. .
We still need the name of the host. To do this, we enter the command in our console:
We receive a list of our active containers. The host name will be related to the mariadb engine:
78582457150a wardenenv/mariadb:10.4 "docker-entrypoint.s…" 22 minutes ago Up 22 minutes 3306/tcp example_db_1
In our case it is example_db_1.
We move on. Add a project name, user name and password. Done, we have received the WordPress project using the docker and warden tool.
With CLI warden we created the WordPress project using docker. Preparation of the environment is very simple and fast, and with the help of warden we can run several containers with different WordPress projects and they will work locally at the same time without interfering with each other. Warden is quite a little known tool for a docker, but it is very effective and speeds up the process of creating a project environment.
I invite you to read our other articles – Useful articles.