From 25a9c412ccb0ce8b4e36957e5cbba7d45642d88e Mon Sep 17 00:00:00 2001 From: Huw Diprose Date: Mon, 18 Jan 2021 15:19:29 +0000 Subject: [PATCH 1/4] Update ruby docker version to 2.7.2 This is the version content publisher currently targets, we should build using the same version here --- source/manual/intro-to-docker.html.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/manual/intro-to-docker.html.md b/source/manual/intro-to-docker.html.md index 8faf2d60d11..4b3f93c72d7 100644 --- a/source/manual/intro-to-docker.html.md +++ b/source/manual/intro-to-docker.html.md @@ -37,12 +37,12 @@ Docker version 18.09.2, build 6247962 * Run from the root of the [content-publisher] project: ```shell -$mac docker run -it ruby:2.6.3 bash +$mac docker run -it ruby:2.7.2 bash ``` -`ruby:2.6.3` is the "image" that we specify. Using object oriented programming as an analogy, an image is like a "class". When we "instantiate" an instance of a class, these are called "containers". +`ruby:2.7.2` is the "image" that we specify. Using object oriented programming as an analogy, an image is like a "class". When we "instantiate" an instance of a class, these are called "containers". -The `ruby:2.6.3` image we are using is a debian system with Ruby pre-installed. Images are downloaded from the [Docker Registry][docker-registry]. The `bash` argument at the end will execute this inside the container, which means we get a bash shell. +The `ruby:2.7.2` image we are using is a debian system with Ruby pre-installed. Images are downloaded from the [Docker Registry][docker-registry]. The `bash` argument at the end will execute this inside the container, which means we get a bash shell. What are the flags? @@ -59,7 +59,7 @@ $mac docker run --help * Mount your current directory as a volume to the container by running: ```shell -$mac docker run -it -v $(pwd):/app ruby:2.6.3 bash +$mac docker run -it -v $(pwd):/app ruby:2.7.2 bash ``` This will map your current directory (the root of the [content-publisher] project) to `/app` inside of the container. So now the files on your `$mac` for [content-publisher] are now also available inside of the container. @@ -71,7 +71,7 @@ $dev cd /app $dev bundle install ``` -> Note: you may need to use a different image (e.g. `ruby:2.6.5`) depending on the version specified in [`.ruby-version`][content-publisher-ruby] in [content-publisher]. +> Note: you may need to use a different image (e.g. `ruby:2.7.2`) depending on the version specified in [`.ruby-version`][content-publisher-ruby] in [content-publisher]. > > Note: this may take a while, so feel free to stop it by pressing Ctrl+c as the next step will show why it doesn't matter at this point. @@ -94,7 +94,7 @@ $mac docker volume create content-publisher-bundle * Run docker with that volume by using the `-v` flag and passing it the name of the volume: ```shell -$mac docker run -it -v $(pwd):/app -v content-publisher-bundle:/usr/local/bundle ruby:2.6.3 bash +$mac docker run -it -v $(pwd):/app -v content-publisher-bundle:/usr/local/bundle ruby:2.7.2 bash ``` * Then install the gems again: @@ -116,7 +116,7 @@ $dev bundle exec rake We get an error: “could not find javascript runtime” - we need Node installed on our container. We can try to install Node here, but this won't persist and we'll have the same problem that we had above with installing gems. -Unlike gems, our install of Node won't need to change in the foreseeable future. It would be nice if our `ruby:2.6.3` image had it as well. We can't change the `ruby:2.6.3` image, but we can create our own image based off it. +Unlike gems, our install of Node won't need to change in the foreseeable future. It would be nice if our `ruby:2.7.2` image had it as well. We can't change the `ruby:2.7.2` image, but we can create our own image based off it. ### Create ruby + node image @@ -133,7 +133,7 @@ Create a Dockerfile in the content-publisher project: * Create a `Dockerfile` in the root of the [content-publisher] project: ```docker -FROM ruby:2.6.3 +FROM ruby:2.7.2 RUN curl -sL https://deb.nodesource.com/setup_12.x | bash RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - From 19c6b6e20ef7248be7c11e426294fe4569c6b768 Mon Sep 17 00:00:00 2001 From: Huw Diprose Date: Mon, 18 Jan 2021 15:15:22 +0000 Subject: [PATCH 2/4] Small improvements to intro to Docker Rather than have to keep this up to date with the latest docker version or risk a user being confused if their terminal shows a different version to whats in the docs, I've replaced these with placeholders and a link to find the latest version of Docker Engine. Add a note about how to exit the docker terminal Most users will likely have the CLI-fu to do this, but on the off chance a user might feel "trapped" inside this shell-within-a-shell, I've added a short note about the `exit` command. --- source/manual/intro-to-docker.html.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/manual/intro-to-docker.html.md b/source/manual/intro-to-docker.html.md index 4b3f93c72d7..e7961f9fe74 100644 --- a/source/manual/intro-to-docker.html.md +++ b/source/manual/intro-to-docker.html.md @@ -29,9 +29,11 @@ Before you start, make sure you: ```shell $mac docker --version -Docker version 18.09.2, build 6247962 +Docker version , build ``` +The [Docker Engine release notes](https://docs.docker.com/engine/release-notes/) list the latest version number. + ### Images and containers * Run from the root of the [content-publisher] project: @@ -44,6 +46,8 @@ $mac docker run -it ruby:2.7.2 bash The `ruby:2.7.2` image we are using is a debian system with Ruby pre-installed. Images are downloaded from the [Docker Registry][docker-registry]. The `bash` argument at the end will execute this inside the container, which means we get a bash shell. +You can leave the shell by typing `exit`. + What are the flags? ```shell From 4f2f9097563be66b90ad91fb2c745eb6e4f96d9f Mon Sep 17 00:00:00 2001 From: Huw Diprose Date: Tue, 19 Jan 2021 17:46:18 +0000 Subject: [PATCH 3/4] Fix postgres in docker now requires a POSTGRES_PASSWORD --- source/manual/intro-to-docker.html.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/manual/intro-to-docker.html.md b/source/manual/intro-to-docker.html.md index e7961f9fe74..ea6cd7a68a3 100644 --- a/source/manual/intro-to-docker.html.md +++ b/source/manual/intro-to-docker.html.md @@ -204,7 +204,15 @@ Docker containers are quick to start and it's possible for them to talk to each * In another terminal, run the following to start a new container based on the `postgres` image: ```shell -$mac docker run -it postgres +$mac docker run -e POSTGRES_PASSWORD=password -it postgres +``` + +Before it starts Postgres will check if a password is set. If do not supply a password `docker run` will print an error and fail to start the container. Postgres can set this password with an environment variable. We can supply this to docker with the `-e` flag. + +```shell +$mac docker run --help +... +-e, --env list Set environment variables ``` * Now to see what containers you have, in another terminal run: From 6a69f3303cfd27e8a9e012a1e41cf663c2871b08 Mon Sep 17 00:00:00 2001 From: Huw Diprose Date: Tue, 19 Jan 2021 17:46:38 +0000 Subject: [PATCH 4/4] Add clarifying comment to explain container ID and the unusual name --- source/manual/intro-to-docker.html.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/manual/intro-to-docker.html.md b/source/manual/intro-to-docker.html.md index ea6cd7a68a3..ebea06f82b2 100644 --- a/source/manual/intro-to-docker.html.md +++ b/source/manual/intro-to-docker.html.md @@ -222,10 +222,11 @@ $mac docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a7b87be3e1bc postgres "docker-entrypoint.s…" 21 minutes ago Up 21 minutes 5432/tcp jovial_matsumoto -... ``` -This shows us that `a7b87be3e1bc` or "jovial_matsumoto" is up and running. We can "inspect" the configuration of the container and get its IP, which we can use in the content-publisher container. +When containers spin up they are assigned an ID, in this case `a7b87be3e1bc`. Containers also have name. If you do not supply one it will default to a random one, in this case `jovial_matsumoto`. + +We can see from running `docker ps` that `a7b87be3e1bc` or "jovial_matsumoto" is up and running. We can "inspect" the configuration of the container and get its IP, which we can use in the content-publisher container. * Find the ID for the postgres container, and with it run: