Cloud Native Course Labs

Sock Shop on Docker Compose

Sock Shop is a microservices demo app. It runs as lots of small services which each own their own data, using the appropriate technology stack and communication pattern for that component.

Each part of the app is packaged and published as container images on Docker Hub, and you can model and run the whole app using Docker Compose.

Reference

Run the app

The Compose file is in sockshop/docker.

There are lots of container images so it will be useful to pull them all before you run the app.

📋 Pull the images and start the app with Compose.

Not sure how?
# pulls all the images in the model:
docker-compose -f ./sockshop/docker/docker-compose.yml pull

# starts all containers in detached mode:
docker-compose -f ./sockshop/docker/docker-compose.yml up -d

When you run the project you'll see a warning about the MySQL password - you can ignore it.

📋 Check all the containers are running, find the entrypoint to the app and browse to it. and browse to the app.

Not sure how?
# this will show container status and published ports:
docker-compose -f ./sockshop/docker/docker-compose.yml ps

Your local Sock Shop deployment should look like this:

The Sock Shop web application

You can log in with these credentials:

Then you can add an item to your cart and checkout. The full user experience should work correctly and you should see your order status changed to shipped.

Explore the Compose file

Read through the Compose model in docker-compose.yml.

Can you answer these questions about the app?

How does the model use these features of Compose?

Do those features mean the model is production-ready?

Manage the app

Check the application logs

You can use the Compose command line to check container logs, and map out the workflow when an order is placed.

📋 Start by checking the logs from the front-end website.

Not sure how?
docker-compose -f ./sockshop/docker/docker-compose.yml logs front-end

The user and payment services also show useful logs.

Scale the app

Scale up the front-end service up to three containers. Check the app - are you still logged in?

📋 Remove the first container and check again.

Not sure how?
docker-compose -f ./sockshop/docker/docker-compose.yml up -d --scale front-end=3

docker rm -f docker_front-end_1

The front end is a stateful app, it stores user sessions locally in each container.

Clean up

📋 Remove the app containers with Compose.

Not sure how?
docker-compose -f ./sockshop/docker/docker-compose.yml down