Docker | Install – Wordpress | Ghost (migrate wp to gh?) *

Docker Commands

https://towardsdatascience.com/15-docker-commands-you-should-know-970ea5203421

First, we’ll look at commands for containers and then we’ll look at commands for images. Volumes will be covered in the next article. Here’s the list of 15 commands to know — plus 3 bonus commands!

Containers
Use docker container my_command

create — Create a container from an image.
start — Start an existing container.
run — Create a new container and start it.
ls — List running containers.
inspect — See lots of info about a container.
logs — Print logs.
stop — Gracefully stop running container.
kill —Stop main process in container abruptly.
rm— Delete a stopped container.

Images

Use docker image my_command
build — Build an image.
push — Push an image to a remote registry.
ls — List images.
history — See intermediate image info.
inspect — See lots of info about an image, including the layers.
rm — Delete an image.

Misc
docker version — List info about your Docker Client and Server versions.
docker login — Log in to a Docker registry.
docker system prune — Delete all unused containers, unused networks, and dangling images.

Migrate Wordpress to Ghost?

https://ghost.org/docs/migration/wordpress/

InstallWP - thoroughInstall WordpressInstall Ghost

https://upcloud.com/community/tutorials/wordpress-with-docker/

Docker is a container platform that allows simple and fast software installations on any system and OS. It wraps the piece of software in a complete file system that includes everything it needs to run such as code, runtime, system tools and libraries. This allows anyone to package an application with its dependencies into a standardized building block.

 

Install Docker

 

Installing Docker itself is already easy. Firstly run the usual update command for your system to make sure you have the latest source lists.

# Debian and Ubuntu
sudo apt-get update
# CentOS
sudo yum update

Check that you have the curl command line utility.

curl -V

It comes preinstalled with most Linux distributions, but if it can not be found, install it manually with the appropriate command for your OS.

# Debian and Ubuntu
sudo apt-get install curl
# CentOS
sudo yum install curl

Use the command below to download and install Docker. The process requires root privileges so you will be asked for your sudo password on any non-root user.

curl -fsSL https://get.docker.com/ | sh

Towards the end of the installation process, you will see a suggestion to add your username to the Docker users group. Doing this allows you to run Docker commands without needing to invoke sudo every time.

sudo usermod -aG docker <username>

Log out and back in again after adding yourself to the Docker users group before continuing.

You can check that the installation was successful with the following test program:

docker run hello-world

You should see an output similar to the example below.

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
...
Hello from Docker.
This message shows that your installation appears to be working correctly.
...

If the command does not work immediately, restart the Docker service with the following and try to run the hello-world app again.

sudo systemctl restart docker

Docker should now be installed and working correctly. Continue on below with the rest of the WordPress setup.

 

MariaDB in a container

 

Before installing WordPress with Docker you will need to have somewhere to store the data. MariaDB is a community-developed relational database management system and a drop-in replacement for MySQL. It is officially available on Docker and provides easy instructions with up to date images.

Start off by making a new directory where you wish to store the files for WordPress and MariaDB for example in your home directory.

mkdir ~/wordpress && cd ~/wordpress

Downloading and installing a new MariaDB container can all be performed with a single command. Before jumping in check the required parameters.

MariaDB Environment variables are marked in the Docker command with -e:

  • -e MYSQL_ROOT_PASSWORD= Set your own password here.
  • -e MYSQL_DATABASE= Creates and names a new database e.g. wordpress.

Docker parameters:

  • –name wordpressdb – Names the container.
  • -v “$PWD/database”:/var/lib/mysql – Creates a data directory linked to the container storage to ensure data persistence.
  • -d – Tells Docker to run the container in daemon.
  • mariadb:latest – Finally defines what to install and which version.

Then run the command below while replacing the with your own.

docker run -e MYSQL_ROOT_PASSWORD=<password> -e MYSQL_DATABASE=wordpress --name wordpressdb -v "$PWD/database":/var/lib/mysql -d mariadb:latest
...
Status: Downloaded newer image for mariadb:latest
23df0ec2e48beb1fb8704ba612e9eb083f4193ecceb11102bc91232955cccc54

If Docker was successful at creating the container, you should see a code at the end of the output similar to the example above. You can confirm that the MariaDB container is running by using the following command:

docker ps

Check the status for your MariaDB install, it should show “Up” and the time it has been running like in the example output below.

CONTAINER ID IMAGE          COMMAND                CREATED        STATUS        PORTS      NAMES
14649c5b7e9a mariadb:latest "/docker-entrypoint.s" 12 seconds ago Up 12 seconds 3306/tcp   wordpressdb

Other useful commands for working with containers are ‘start’, ‘stop’ and ‘remove’.

docker start <container name>
docker stop <container name>
docker rm <container name>

You can find out more about available commands and options for specific commands.

docker --help
docker <command> --help

Full command-line documentation is also available over at the Docker support page.

 

WordPress with Docker

 

Applications in containers run isolated from one another in the userspace of the host operating system sharing the kernel with other containers. This reduces the overhead required to run packaged software while also enabling the containers to run on any kind of infrastructure. To allow applications within different containers to work with one another Docker supports container linking.

WordPress is also made officially available on Docker Hub, pull the image using the command below. When the version to download is not specified Docker will fetch the latest available.

docker pull wordpress

WordPress container also takes environment variables and Docker parameters:

  • -e WORDPRESS_DB_PASSWORD= Set the same database password here.
  • –name wordpress – Gives the container a name.
  • –link wordpressdb:mysql – Links the WordPress container with the MariaDB container so that the applications can interact.
  • -p 80:80 – Tells Docker to pass connections from your server’s HTTP port to the containers internal port 80.
  • -v “$PWD/html”:/var/www/html – Sets the WordPress files accessible from outside the container. The volume files will remain even if the container was removed.
  • -d – Makes the container run on background
  • wordpress – Tells Docker what to install. Uses the package downloaded earlier with the docker pull wordpress -command.

Run the command below while replacing the as you did for the MariaDB container.

docker run -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=<password> --name wordpress --link wordpressdb:mysql -p 80:80 -v "$PWD/html":/var/www/html -d wordpress

Then open your server’s domain name or IP address in a web browser to test the installation. You should be redirected to the initial WordPress setup page at http:///wp-admin/install.php. Go through the setup wizard and you are done.

WordPress initial setup page

If you get an error linking your server’s public IP address to the WordPress container’s internal address, remove the failed container using the following command:

docker rm wordpress

Restart Docker and the database container, also make sure no other service is already bound to port 80.

sudo systemctl restart docker
docker start wordpressdb

Then try creating the WordPress container again.

 

Conclusions

 

Congratulations, you should now have a simple WordPress with Docker running in a container and an easy way to configure another one if needed. Before continuing on building your new WordPress site, make sure to pay attention to the security on your server. To find out more, check out our article for How To Secure Your Linux Cloud Server.

https://www.hostinger.com/tutorials/run-docker-wordpress

How to Install WordPress on Docker (Windows, macOS and Linux)

If you are looking for a way to create isolated environments to test your WordPress, then familiarize yourself with container technology. In this article, we’ll cover a step-by-step guide to install WordPress on Docker, the best-known container platform.

What Exactly Is Docker?How to Install WordPress on Docker?Step 1 Installing DockerStep 2 Setting-Up WordPress on Docker

What Exactly Is Docker?

Docker is an open-source containerization software that creates isolated environments to run an application. Hence, you develop, test, and run multiple applications on the same machine.

In contrast to virtual machines, each container does not require its own OS and shares the host’s kernel. Thus, the machine’s workload is far more lightweight and a single server can run multiple containers at the same time.

For that reason, Docker is highly useful for WordPress developers. A WordPress test environment usually eats up a lot of system resources, but Docker helps them make a minimal environment without wasting server space and memory.

How to Install WordPress on Docker?

Follow the steps below and learn how to install WordPress on Docker.

Step 1: Installing Docker

Docker is available for Windows, macOS, and Linux. Here’s how you can install it on those three operating systems:

https://docs.docker.com/install/

macOS X Installation

Here are the procedures to install Docker on macOS:

  1. Download Docker for Mac and double-click the .dmg file you’ve saved. Then, drag and drop the Docker icon to your Applications folder.
  2. Open your Applications folder and double-click docker.app. During the configuration process, you’ll be asked to enter your password.
  3. Once the installation process is finished, you’ll see the docker menu in your desktop’s status bar.

Windows Installation

Here’s how you can install Docker on Windows 10 64-bit:

  1. Enable Hyper-V in your system.
  2. Download Docker Desktop for Windows and open the Docker for Windows Installer file.
  3. In the Configuration dialog window, check or uncheck the boxes based on your preferences. Click Ok.
  4. Once the installation is finished, hit Close. You’ll see the Docker icon in the taskbar.

Step 2: Setting-Up WordPress on Docker

Next, let’s set up WordPress on Docker. You can do this process with these two methods ‒ the CLI and Docker compose.

In this article, we’ll be using Docker compose, the cleaner and more systematic method. Here’s how:

  1. Check Docker Compose

    Installation:

    docker-compose –version

  2. Create a new directory for WordPress:

    mkdir ~/wordpress/

    cd ~/wordpress/

  3. Create a new

    docker-compose.yml

    in the new directory and paste the content below. Don’t forget to change the credentials.

    version: '3.3'

    services:

    db:

    image: mysql:5.7

    volumes:

    – db_data:/var/lib/mysql

    restart: always

    environment:

    MYSQL_ROOT_PASSWORD: somewordpress

    MYSQL_DATABASE: wordpress

    MYSQL_USER: wordpress

    MYSQL_PASSWORD: wordpress

    wordpress:

    depends_on:

    – db

    image: wordpress:latest

    ports:

    – "8000:80"

    restart: always

    environment:

    WORDPRESS_DB_HOST: db:3306

    WORDPRESS_DB_USER: wordpress

    WORDPRESS_DB_PASSWORD: wordpress

    WORDPRESS_DB_NAME: wordpress

    volumes:

    db_data: {}

  4. Run this command in the directory to create the containers:

    docker-compose up -d

  5. Your browser will enter localhost:8000 and display

Conclusion

Docker is a great containerization tool to experiment with WordPress. Its minimal environment helps you maintain the efficiency of your system resources.

In this tutorial, you’ve learned how to install Docker on Linux, macOS, and Windows. You’ve also learned how to set up WordPress on Docker using the Docker Compose utility.

We hope this simple tutorial is helpful. If have any further questions, share with us in the comments section below.

 


https://ghost.org/docs/install/docker/
https://github.com/docker-library/ghost

How to install Ghost with Docker

The Docker image for Ghost is an unofficial community package maintained by people within the Ghost developer community.

Resources

Resources and downloads:

Ghost

Ghost is a free and open source blogging platform written in JavaScript and distributed under the MIT License, designed to simplify the process of online publishing for individual bloggers as well as online publications.

wikipedia.org/wiki/Ghost_(blogging_platform)

How to use this image

This will start a Ghost instance listening on the default Ghost port of 2368.

$ docker run -d --name some-ghost ghost

Custom port

If you’d like to be able to access the instance from the host without the container’s IP, standard port mappings can be used:

$ docker run -d --name some-ghost -e url=http://localhost:3001 -p 3001:2368 ghost

If all goes well, you’ll be able to access your new site on http://localhost:3001 and http://localhost:3001/ghost to access Ghost Admin (or http://host-ip:3001 and http://host-ip:3001/ghost, respectively).

Upgrading Ghost

You will want to ensure you are running the latest minor version of Ghost before upgrading major versions. Otherwise, you may run into database errors.

For upgrading your Ghost container you will want to mount your data to the appropriate path in the predecessor container (see below): import your content from the admin panel, stop the container, and then re-mount your content to the successor container you are upgrading into; you can then export your content from the admin panel.

Stateful

Mount your existing content. In this example we also use the Alpine base image.

$ docker run -d --name some-ghost -p 3001:2368 -v /path/to/ghost/blog:/var/lib/ghost/content ghost:alpine

Docker Volume

Alternatively you can use a named docker volume instead of a direct host path for /var/lib/ghost/content:

$ docker run -d --name some-ghost -v some-ghost-data:/var/lib/ghost/content ghost

SQLite Database

This Docker image for Ghost uses SQLite. There is nothing special to configure.

Configuration

All Ghost configuration parameters (such as url) can be specified via environment variables. See the Ghost documentation for details about what configuration is allowed and how to convert a nested configuration key into the appropriate environment variable name:

$ docker run -d --name some-ghost -e url=http://some-ghost.example.com ghost

(There are further configuration examples in the stack.yml listed below.)

What is the Node.js version?

When opening a ticket at https://github.com/TryGhost/Ghost/issues it becomes necessary to know the version of Node.js in use:

$ docker exec <container-id> node --version
[node version output]

Note about Ghost-CLI

While the Docker images do have Ghost-CLI available and do use some of its commands to set up the base Ghost image, many of the other Ghost-CLI commands won’t work correctly, and really aren’t designed/intended to. For more info see docker-library/ghost#156 (comment)

… via  or 

Example stack.yml for ghost:

# by default, the Ghost image will use SQLite (and thus requires no separate database container)
# we have used MySQL here merely for demonstration purposes (especially environment-variable-based configuration)

version: '3.1'

services:

  ghost:
    image: ghost:3-alpine
    restart: always
    ports:
      - 8080:2368
    environment:
      # see https://ghost.org/docs/config/#configuration-options
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: example
      database__connection__database: ghost
      # this url value is just an example, and is likely wrong for your environment!
      url: http://localhost:8080
      # contrary to the default mentioned in the linked documentation, this image defaults to NODE_ENV=production (so development mode needs to be explicitly specified if desired)
      #NODE_ENV: development

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example

Run docker stack deploy -c stack.yml ghost (or docker-compose -f stack.yml up), wait for it to initialize completely, and visit http://swarm-ip:8080http://localhost:8080, or http://host-ip:8080 (as appropriate).

Image Variants

The ghost images come in many flavors, each designed for a specific use case.

ghost:<version>

This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.

ghost:<version>-alpine

This image is based on the popular Alpine Linux project, available in the alpine official image. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.

This variant is useful when final image size being as small as possible is your primary concern. The main caveat to note is that it does use musl libc instead of glibc and friends, so software will often run into issues depending on the depth of their libc requirements/assumptions. See this Hacker News comment thread for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.

To minimize image size, it’s uncommon for additional related tools (such as git or bash) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the alpine image description for examples of how to install packages if you are unfamiliar).

License

View license information for the software contained in this image.

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

Some additional license information which was able to be auto-detected might be found in the repo-info repository’s ghost/ directory.

As for any pre-built image usage, it is the image user’s responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

Scroll to Top