Skip to content

Commit

Permalink
fixed some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
btholt committed Apr 25, 2024
1 parent d0af3bd commit 95163e5
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Containers are probably simpler than you think they are. Before I took a deep dive into what they are, I was very intimidated by the concept of what containers were. I thought they were for one super-versed in Linux and sysadmin type activties. In reality, the core of what containers are is just a few features of the Linux kernel duct-taped together. Honestly, there's no single concept of a "container": it's just using a few features of Linux together to achieve isolation. That's it.

So how comfortable are you with the command line? This course doesn't assume wizardry with bash or zsh but this probably shouldn't be your first adventure with it. If it is, [check out my course on the command line and Linux][cli]. This course will give you more than we'll need to keep up with this course.
So how comfortable are you with the command line? This course doesn't assume wizardry with bash or zsh but this probably shouldn't be your first adventure with it. If it is, [check out my course on the command line and Linux][linux]. This course will give you more than we'll need to keep up with this course.

## Why Containers

Expand Down
7 changes: 4 additions & 3 deletions lessons/02-crafting-containers-by-hand/C-namespaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ So let's create a chroot'd environment now that's isolated using namespaces usin

**NOTE**: This next command downloads about 150MB and takes at least a few minutes to run. Unlike Docker images, this will redownload it _every_ time you run it and does no caching.

``bash
exit # from our chroot'd environment if you're still running it, if not skip this
````bash
# from our chroot'd environment if you're still running it, if not skip this
exit

## Install debootstrap

Expand All @@ -43,7 +44,7 @@ unshare --mount --uts --ipc --net --pid --fork --user --map-root-user chroot /be
mount -t proc none /proc # process namespace
mount -t sysfs none /sys # filesystem
mount -t tmpfs none /tmp # filesystem
```
````
This will create a new environment that's isolated on the system with its own PIDs, mounts (like storage and volumes), and network stack. Now we can't see any of the processes!
Expand Down
2 changes: 1 addition & 1 deletion lessons/03-docker/B-docker-images-with-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Now you can refer to these by a name you set. But now if you tried it again, it'
In the future you can just do

```bash
docker run --rm -dit --name my-ubuntu ubuntu:bionic
docker run --rm -dit --name my-ubuntu ubuntu:jammy
docker kill my-ubuntu
```

Expand Down
4 changes: 2 additions & 2 deletions lessons/03-docker/D-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
So far we've just been running containers with random tags that I chose. If you run `docker run -it node` the tag implicitly is using the `latest` tag. When you say `docker run -it node`, it's the same as saying `docker run -it node:latest`. The `:latest` is the tag. This allows you to run different versions of the same container, just like you can install React version 17 or React version 18: some times you don't want the latest. Let's say you have a legacy application at your job and it depends on running on Node.js 12 (update your app, Node.js is already past end-of-life) then you can say

```bash
docker run -it node:12 bash
docker run -it node:20 bash
```

Once in the shell, run `node --version` and you'll see the Node.js version is 12._._! Neat! This is helpful because now we can fix our Node.js version to the one our app expects. Hop back over to [the Docker Hub page for the node container][node]. Take a look at all the version of the node container you can download. Let's try another one.
Once in the shell, run `node --version` and you'll see the Node.js version is 20._._! Neat! This is helpful because now we can fix our Node.js version to the one our app expects. Hop back over to [the Docker Hub page for the node container][node]. Take a look at all the version of the node container you can download. Let's try another one.

```bash
docker run node:20-alpine cat /etc/issue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Now try building and running your container. It should work now! Yay!

> **NOTE:** Make sure you don't bind your app to host `localhost` (like if you put `localhost` instead of `0.0.0.0` in the host in our Fastify app.) This will make it so the app is only available _inside_ the container. If you see `connection reset` instead of when you're expecting a response, this a good candidate for what's happening (because this definitely didn't _just_ happen to me 😂.)
[node-file]: https://github.com/btholt/project-files-for-complete-intro-to-containers-v2/blob/main/build-a-more-complicated-nodejs-app/main.js
[node-file]: https://github.com/btholt/project-files-for-complete-intro-to-containers-v2/blob/main/build-a-more-complicated-nodejs-app/package.json
[node-file]: https://github.com/btholt/project-files-for-complete-intro-to-containers-v2/blob/main/build-a-more-complicated-nodejs-app/index.js
[package-file]: https://github.com/btholt/project-files-for-complete-intro-to-containers-v2/blob/main/build-a-more-complicated-nodejs-app/package.json
[dockerfile-file]: https://github.com/btholt/project-files-for-complete-intro-to-containers-v2/blob/main/build-a-more-complicated-nodejs-app/Dockerfile
[fastify]: https://fastify.dev/
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ CMD ["node", "index.js"]

[⛓️ Link to the Dockerfile][dockerfile-file]

It works! We're down to 89MB (compared to 150MB-ish with the official `node:12-alpine` container). Honestly, I'm not entirely sure what we cut out from the other `node:20-alpine` container but it's probably important. Again, I'd stick to the official containers where they exist. But hey, we learned how to add a user and install system dependencies! Let's make it even small because why the hell not.
It works! We're down to 89MB (compared to 150MB-ish with the official `node:20-alpine` container). Honestly, I'm not entirely sure what we cut out from the other `node:20-alpine` container but it's probably important. Again, I'd stick to the official containers where they exist. But hey, we learned how to add a user and install system dependencies! Let's make it even small because why the hell not.

[dockerfile-file]: https://github.com/btholt/project-files-for-complete-intro-to-containers-v2/blob/main/making-our-own-alpine-nodejs-container/Dockerfile
[dockerfile-file]: https://github.com/btholt/project-files-for-complete-intro-to-containers-v2/blob/main/make-our-own-alpine-nodejs-container/Dockerfile

0 comments on commit 95163e5

Please sign in to comment.