{"id":1364,"date":"2026-06-14T16:03:07","date_gmt":"2026-06-14T16:03:07","guid":{"rendered":"https:\/\/johnnycarlos.com\/?p=1364"},"modified":"2026-06-14T16:32:02","modified_gmt":"2026-06-14T16:32:02","slug":"containerizing-my-wordpress-blog","status":"publish","type":"post","link":"https:\/\/johnnycarlos.com\/index.php\/2026\/06\/14\/containerizing-my-wordpress-blog\/","title":{"rendered":"Containerizing my WordPress Blog"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I&#8217;ve decided it&#8217;s finally time to learn containerization and am going to start with this blog.  I&#8217;m running Ubuntu 24.04 and will be installing from the offical Docker repo since it&#8217;s the latest release.  The Ubuntu repo often lags behind the official release.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1 &#8211;<\/strong>  Check if ca-certificates are installed.  In order to download the packages from the Docker servers, curl will check the certificates to make sure it is legitimate:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dpkg -l ca-certificates<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2<\/strong> &#8211; Check that there is a directory for the keyrings.  It&#8217;s the designated place to store apt repository signing keys on Ubuntu:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -ld \/etc\/apt\/keyrings<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 3 &#8211; <\/strong>Next I downloaded the key and made sure it was readable by all users:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo curl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg -o \/etc\/apt\/keyrings\/docker.asc\nsudo chmod a+r \/etc\/apt\/keyrings\/docker.asc<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 4 &#8211;<\/strong> Next I added the Docker apt repository:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \\\n  \"deb &#91;arch=$(dpkg --print-architecture) signed-by=\/etc\/apt\/keyrings\/docker.asc] \\\n  https:\/\/download.docker.com\/linux\/ubuntu \\\n  $(. \/etc\/os-release &amp;&amp; echo \"${UBUNTU_CODENAME:-$VERSION_CODENAME}\") stable\" | \\\n  sudo tee \/etc\/apt\/sources.list.d\/docker.list > \/dev\/null<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check it with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/etc\/apt\/sources.list.d\/docker.list<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 5 &#8211;<\/strong> Update and install:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check that it works:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo docker run hello-world<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 6 &#8211;<\/strong> Give myself permission to run Docker without sudo:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo usermod -aG docker $USER<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Some Basic Commands<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">Images<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>docker images                  # list images on your system\ndocker pull ubuntu             # download an image\ndocker rmi ubuntu              # remove an image<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Containers<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>docker ps                      # list running containers\ndocker ps -a                   # list all containers (including stopped)\ndocker run hello-world         # run a container from an image\ndocker run -it ubuntu bash     # run interactively with a shell\ndocker stop &lt;name\/id>          # stop a running container\ndocker rm &lt;name\/id>            # remove a stopped container<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Useful Run Flags<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d ...              # detached (background)\ndocker run -p 8080:80 ...      # map host port 8080 to container port 80\ndocker run --name myapp ...    # give it a name instead of a random one<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Housekeeping<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>docker system df               # see how much disk Docker is using\ndocker system prune            # clean up stopped containers, unused images, etc.<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Logs and Inspection<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>docker logs &lt;name\/id>          # view container output\ndocker inspect &lt;name\/id>       # detailed info about a container or image<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Notes to Myself<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You cant delete an image if the container exists.  And if the container is stopped, then <code>docker ps<\/code> won&#8217;t show it, you need to do <code>docker ps -a<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve decided it&#8217;s finally time to learn containerization and am going to start with this blog. I&#8217;m running Ubuntu 24.04 and will be installing from the offical Docker repo since it&#8217;s the latest release. The Ubuntu repo often lags behind the official release. Step 1 &#8211; Check if ca-certificates are installed. In order to download [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"cybocfi_hide_featured_image":"","footnotes":""},"categories":[28,36,29],"tags":[],"class_list":["post-1364","post","type-post","status-publish","format-standard","hentry","category-blog","category-linux","category-today-i-learned"],"_links":{"self":[{"href":"https:\/\/johnnycarlos.com\/index.php\/wp-json\/wp\/v2\/posts\/1364","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/johnnycarlos.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/johnnycarlos.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/johnnycarlos.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/johnnycarlos.com\/index.php\/wp-json\/wp\/v2\/comments?post=1364"}],"version-history":[{"count":4,"href":"https:\/\/johnnycarlos.com\/index.php\/wp-json\/wp\/v2\/posts\/1364\/revisions"}],"predecessor-version":[{"id":1368,"href":"https:\/\/johnnycarlos.com\/index.php\/wp-json\/wp\/v2\/posts\/1364\/revisions\/1368"}],"wp:attachment":[{"href":"https:\/\/johnnycarlos.com\/index.php\/wp-json\/wp\/v2\/media?parent=1364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/johnnycarlos.com\/index.php\/wp-json\/wp\/v2\/categories?post=1364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/johnnycarlos.com\/index.php\/wp-json\/wp\/v2\/tags?post=1364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}