Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ii:labs:s2:05:tasks:01 [2022/05/31 15:01]
radu.ciobanu
ii:labs:s2:05:tasks:01 [2025/05/21 08:38] (current)
florin.stancu [01. [30p] Running a multi-container application]
Line 1: Line 1:
-==== 01. [30p] Starting ​a multi-node Docker Swarm cluster ​==== +==== 01. [30p] Running ​a multi-container application ​====
- +
-For this task, we will start a Docker Swarm cluster composed of three nodes (one manager and two workers) on Play with Docker. In order to add a new node to the cluster, you need to press the "Add a new instance button"​ as shown in the image below. +
- +
-TODO +
- +
-After adding one or more nodes, you will see a list with each one on the left-hand side, together with their IP and hostname (e.g., in the image below, //​**node1**//​ has IP 192.168.0.28). By clicking on each node, you obtain a window containing a shell into that node. +
- +
-TODO+
  
 == Subtasks == == Subtasks ==
  
-  - log into Play with Docker +  - based on the sources and the Dockerfile in the //​**backend**//​ folder from the lab archive, build an image with the name **//​lab5-api-image//​** 
-  - add three nodes +  - create a bridge network called **//​lab5-db-network//​** 
-  - on //**node1**//, initialise ​Docker Swarm cluster ​with the "docker swarm init %%--%%advertise-addr <IP>" ​command ​(you can use the IP address shown in the node description on the left-hand size of the Play with Docker page+  - create another bridge network called **//​lab5-adminer-network//** 
-  - add //**node2**// and //**node3**// to the cluster by running ​the command shown in the output of the cluster creation command (it looks like "​docker swarm join --token [...]"​) +  - create a volume named **//​lab5-db-volume//​** 
-  - verify that the cluster was created ​successfully by running ​the "​docker node ls" command on //**node1**// (you should see all three nodes in the output) +  - from the parent folder of //**backend**//, launch ​container //**in the background**//​ for a database ​with the following features: 
- +    - a bind mount will be attached that will map between the **//%%"%%$(pwd)%%"%%/​database/​init-db.sql//​** file on the local machine ​(this will be the source to the bind mount flag and can be found in the lab archive) and the **///​docker-entrypoint-initdb.d/​init-db.sql//​** file in the container to be run (this will be the destination) 
-== What to upload ==+    ​attach ​the previously-created **//​lab5-db-volume//​** volume (as sourceto the **///​var/​lib/​postgresql/​data//​** path in the running container (as destination) 
 +    - the container will be part the previously-created **//​lab5-db-network//​** network 
 +    - the following environment variables will be specified (in a **//docker run//** command, this is done as follows: **// docker run -e NAME=value//​**):​ 
 +      - variable **//​POSTGRES_USER//​** with value **//​admin//​** 
 +      - variable **//​POSTGRES_PASSWORD//​** with value **//​admin//​** 
 +      - variable **//​POSTGRES_DB//​** with value **//​books//​** 
 +    - the container will be called **//​lab5-db//​** 
 +    - the container will run the **//​postgres//​** image from the official register 
 +  - add the **//lab5-db//** container to the **//lab5-adminer-network//** network 
 +  - launch a container //**in the background**// for a database admin with the following features: 
 +    - the container will expose port 80 and map it to 8080 on the local machine 
 +    - the container will be called **//​lab5-adminer//​** 
 +    - the container will be part the previously-created **//lab5-adminer-network//​** network 
 +    - the container will run the **//​adminer//​** image from the official register 
 +  - start a container //​**in ​the background**//​ based on the previously-created ​**//​lab5-api-image//​** image, with the following features: 
 +    - the container will be part of the previously-created **//​lab5-db-network//** network 
 +    - the following environment variables will be specified:​ 
 +      - variable ​**//PGUSER//** with value **//​admin//​** 
 +      - variable **//​PGPASSWORD//​** with value **//​admin//​** 
 +      - variable **//​PGDATABASE//​** with the value **//​books//​** 
 +      - variable **//​PGHOST//​** with value **//​lab5-db//​** 
 +      - variable **//​PGPORT//​** with value **//​5432//​** 
 +    - the container will be called **//​lab5-api//​** 
 +    - the container will expose port 80 and map it to port 5555 on the local machine
  
-  * a text file with the commands given on each node 
-  * a print screen with the output of the "​docker node ls" command on //​**node1**//​ 
ii/labs/s2/05/tasks/01.1653998479.txt.gz · Last modified: 2022/05/31 15:01 by radu.ciobanu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0