Run Stateless Docker Containers

Share this video with your friends

Send Tweet

Docker containers should be designed to be stateless, meaning that they can survive system reboots and container terminations gracefully, and without the loss of data. Designing with stateless containers in mind will also help your app grow and make future horizontal scaling trivial.

In this lesson, we will review an app that saves uploaded files to the filesystem. Then we will learn how to setup a persistent volume for the uploaded files so they can survive Docker container halts, restarts, stops and respawns.

Harshesh
Harshesh
~ 7 years ago

A question: where does appdata: volume points to?

Mark Shust
Mark Shust(instructor)
~ 7 years ago

The appdata: reference is basically pointing to a new scratch volume. It will store whatever you place on the volume, but outside of any container.

Harshesh
Harshesh
~ 7 years ago

..just clarifying, since the scratch location is not declared, it will consider the current location where we executed docker-compose command?

Mark Shust
Mark Shust(instructor)
~ 7 years ago

No, this volume lives within docker as a docker volume. You can view all docker volumes with the docker volume ls command.

zarcode
zarcode
~ 7 years ago

I get this output:

$docker-compose up Building app Step 1/7 : FROM mhart/alpine-node ERROR: Service 'app' failed to build: Get https://registry-1.docker.io/v2/mhart/alpine-node/manifests/latest: unauthorized: incorrect username or password

Can I get some help?

Mark Shust
Mark Shust(instructor)
~ 7 years ago

That's an odd one -- perhaps you can try again? Almost appears as though docekr.io or dockerhub experienced a server outage.

zarcode
zarcode
~ 7 years ago

You are right, thank you for help.

JP Erasmus
JP Erasmus
~ 7 years ago

Schrödinger's cat - very clever and funny!