0
0
Dockerdevops~30 mins

Blue-green deployment with containers in Docker - Mini Project: Build & Apply

Choose your learning style9 modes available
Blue-green deployment with containers
📖 Scenario: You are managing a web application that needs to be updated without downtime. You will use blue-green deployment with Docker containers to switch between two versions smoothly.
🎯 Goal: Build a simple blue-green deployment setup using Docker containers. You will create two containers named blue and green, configure a variable to track the active container, switch the active container, and finally display which container is currently active.
📋 What You'll Learn
Create two Docker containers named blue and green running a simple web server
Create a variable called active_container to track which container is live
Write a command to switch the active_container from blue to green or vice versa
Print the name of the currently active container
💡 Why This Matters
🌍 Real World
Blue-green deployment helps update applications without downtime by switching traffic between two container versions.
💼 Career
Understanding container management and deployment strategies is essential for DevOps roles to ensure smooth application updates.
Progress0 / 4 steps
1
Create two Docker containers named blue and green
Write two docker run commands to start containers named blue and green using the nginx image in detached mode.
Docker
Need a hint?

Use docker run -d --name container_name nginx to start each container.

2
Create a variable active_container to track the live container
Create a shell variable called active_container and set it to blue to indicate the blue container is currently active.
Docker
Need a hint?

Use active_container=blue to set the variable.

3
Switch the active_container from blue to green
Write a shell command to change the value of active_container from blue to green if it is currently blue. Use an if statement to check the current value.
Docker
Need a hint?

Use if [ "$active_container" = "blue" ]; then active_container=green; fi to switch.

4
Print the name of the currently active container
Write a echo command to display the text Active container is: followed by the value of active_container.
Docker
Need a hint?

Use echo "Active container is: $active_container" to print the active container.