Skip to content

Commit

Permalink
part 2 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mluukkai committed Mar 11, 2024
1 parent 5f2dc1f commit 84f1500
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The course is suitable for anyone interested in Docker or containerization and h
The 2024 edition of the course starts officially on 11th March. The material is currently being updated. At the time of writing (11th March) the following parts have already been updated

- Part 1
- Part 2 up to and including chapter _Migrating to Docker Compose_
- Part 2 up to and including chapter _Docker networking_

You may continue already beyond the updated material but beware, there might be some outdated content!

Expand Down
10 changes: 5 additions & 5 deletions docs/part-2/section-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
title: "Docker networking"
---

Connecting two services such as a server and its Database in docker can be achieved with a [Docker network](https://docs.docker.com/network/). In addition to starting services listed in docker-compose.yml Docker Compose automatically creates and joins both containers into a network with a DNS. Each service is named after the name given in the docker-compose.yml file. As such, containers can reference each other simply with their service names, which is different from the container name.
Connecting two services such as a server and its database in docker can be achieved with a [Docker network](https://docs.docker.com/network/). In addition to starting services listed in docker-compose.yml Docker Compose automatically creates and joins both containers into a network with a [DNS](https://docs.docker.com/network/#dns-services). Each service is named after the name given in the docker-compose.yml file. As such, containers can reference each other simply with their service names, which is different from the container name.

![Docker networks](/img/2/docker-networks.png)

Here are two services in a single network: webapp and webapp-helper. The webapp-helper has a server, listening for requests in port 3000, that webapp wants to access. Because they were defined in the same docker-compose.yml file the access is trivial. Docker Compose has already taken care of creating a network and webapp can simply send a request to webapp-helper:3000, the internal DNS will translate that to the correct access and ports do not have to be published outside of the network.

:::tip Security reminder: Plan your infrastructure and keep to your plan

In the next exercise, and in some later exercises, I will supply you with an illustration of the infrastructure. Do look at it and use it to write the configuration.
In the next exercise, and in some later exercises, there is an illustration of the infrastructure. Have a look at it and use it to write the configuration.

For example, in Exercise 2.4 we don't want to open ports to Redis to the outside world. Do not add a `ports` configuration under Redis! The backend will be able to access the application within the Docker network.

Expand Down Expand Up @@ -97,7 +97,7 @@ networks:
name: database-network # Must match the actual name of the network
```

# Scaling
## Scaling

Compose can also scale the service to run multiple instances:

Expand Down Expand Up @@ -259,7 +259,7 @@ $ curl whoami.colasloth.com
I'm 740dc0de1954
```

Now we have a basic single machine hosting setup up and running.
Now we have a basic single-machine hosting setup up and running.

Test updating the `hello.html` without restarting the container, does it work?

Expand All @@ -269,7 +269,7 @@ Test updating the `hello.html` without restarting the container, does it work?

The project [https://github.com/docker-hy/material-applications/tree/main/scaling-exercise](https://github.com/docker-hy/material-applications/tree/main/scaling-exercise) is a barely working application. Go ahead and clone it for yourself. The project already includes docker-compose.yml so you can start it by running `docker compose up`.

Application should be accessible through [http://localhost:3000](http://localhost:3000). However it doesn't work well enough and I've added a load balancer for scaling. Your task is to scale the `compute` containers so that the button in the application turns green.
The application should be accessible through [http://localhost:3000](http://localhost:3000). However it doesn't work well enough and we've added a load balancer for scaling. Your task is to scale the `compute` containers so that the button in the application turns green.

This exercise was created with [Sasu Mäkinen](https://github.com/sasumaki)

Expand Down

0 comments on commit 84f1500

Please sign in to comment.