To follow this tutorial, you will need the following:
- One Debian 10 server set up by following the Debian 10 initial server setup guide, including a sudo non-root user and a firewall.
- An account on Docker Hub if you wish to create your own images and push them to Docker Hub, as shown in Steps 7 and 8.
Step 1 — Installing Docker
The Docker installation package available in the official Debian repository may not be the latest version. To ensure we get the latest version, we’ll install Docker from the official Docker repository. To do that, we’ll add a new package source, add the GPG key from Docker to ensure the downloads are valid, and then install the package.
First, update your existing list of packages:
Docker ARG, ENV and .env – a Complete Guide
This is a long, in-depth read. Let’s start with something you can use right now, without having to read the whole thing!
Here’s a list of easy takeaways:
- The .env file, is only used during a pre-processing step when working with docker-compose.yml files. Dollar-notation variables like $HI are substituted for values contained in an “.env” named file in the same directory.
- ARG is only available during the build of a Docker image (RUN etc), not after the image is created and containers are started from it (ENTRYPOINT, CMD). You can use ARG values to set ENV values to work around that.
- ENV values are available to containers, but also RUN-style commands during the Docker build starting with the line where they are introduced.
- If you set an environment variable in an intermediate container using bash (RUN export VARI=5 && …) it will not persist in the next command. There’s a way to work around that.
- An env_file, is a convenient way to pass many environment variables to a single command in one batch. This should not be confused with a .env file.
- Setting ARG and ENV values leaves traces in the Docker image. Don’t use them for secrets which are not meant to stick around (well, you kinda can with multi-stage builds).
An Overview
Alright, let’s get started with the details. The guide is split up into the following topics:
- The Dot-Env File (.env)
- ARG and ENV Availability
- Setting ARG Values
- Setting ENV Values
- Overriding ENV Values
Feel free to jump right to the one you need right now. However, you’ll get the best result if you read through them all thoroughly.
The Flask Mega-Tutorial Part XIX: Deployment on Docker Containers
This is the nineteenth installment of the Flask Mega-Tutorial series, in which I’m going to deploy Microblog to the Docker container platform.
For your reference, below is a list of the articles in this series.
- Chapter 1: Hello, World!
- Chapter 2: Templates
- Chapter 3: Web Forms
- Chapter 4: Database
- Chapter 5: User Logins
- Chapter 6: Profile Page and Avatars
- Chapter 7: Error Handling
- Chapter 8: Followers
- Chapter 9: Pagination
- Chapter 10: Email Support
- Chapter 11: Facelift
- Chapter 12: Dates and Times
- Chapter 13: I18n and L10n
- Chapter 14: Ajax
- Chapter 15: A Better Application Structure
- Chapter 16: Full-Text Search
- Chapter 17: Deployment on Linux
- Chapter 18: Deployment on Heroku
- Chapter 19: Deployment on Docker Containers (this article)
- Chapter 20: Some JavaScript Magic
- Chapter 21: User Notifications
- Chapter 22: Background Jobs
- Chapter 23: Application Programming Interfaces (APIs)
The smallest PaaS implementation you’ve ever seen
Dokku helps you build and manage the lifecycle of applications