BM: Baca dalam Bahasa Melayu
World D3: Lockers & Phone Lines
Settings in env files
You will learn: to hand a container many settings at once with --env-file.
Checked with Docker Engine 29 on 31 Oct 2026
The problem
Your laptop~/shop
- No open hatches
Lunchboxes (containers)
- No containers yet
Frozen packs (images)
- alpine:3.221 layers · 12.9MB
0 containers (0 running), 1 images, 0 lockers.
Four settings, four -e flags. One typo and the shop breaks. Your shell history keeps every value, too.
Watch
Tap the line Docker skips.
0 of 1 found
An env file: A settings card: one NAME=value per line, handed over with --env-file. is a settings card: one NAME=value per line. --env-file shop.env hands the whole card to the box.
Try it
Start app with the whole settings card, shop.env.
Your laptop~/shop
- No open hatches
Lunchboxes (containers)
- No containers yet
Frozen packs (images)
- alpine:3.221 layers · 12.9MB
0 containers (0 running), 1 images, 0 lockers.
Hint
Trycat shop.env first to read the card.Predict
quoted.env says SHOP_NAME="Kedai Kancil". What does the app get?
Pick one answer.
Check
Your laptop~/shop
- No open hatches
Lunchboxes (containers)
- No containers yet
Frozen packs (images)
- alpine:3.221 layers · 12.9MB
0 containers (0 running), 1 images, 0 lockers.
Real error: variable 'SHOP_NAME ' contains whitespaces. Plain words: no spaces around the = sign.
Check
Is this a good line for an env file?
Swipe right for good, left for needs work. Or use the buttons.
TZ=Asia/Kuala_LumpurYou did it!
You can now hand a container its settings in one file.
Go deeper (optional)
A line with only NAME copies that value from your laptop, if it is set. Compose reads .env files with its own rules: World D4. Does your env file hold a password? Keep it out of Git: put it in .gitignore.
Real rep (optional):
Real mission
printf "SHOP_NAME=Kedai Kancil\nTZ=Asia/Kuala_Lumpur\n" > shop.envdocker run --rm --env-file shop.env alpine:3.22 envecho "*.env" >> .gitignore
0 of 3 steps done · Your ticks are saved.
Bahasa Melayu
Empat tetapan, empat -e. Satu salah taip dan kedai rosak. Sejarah shell anda pun simpan setiap nilai.
Fail env ialah kad tetapan: satu NAMA=nilai setiap baris. --env-file shop.env serahkan seluruh kad kepada bekas.
Mulakan app dengan seluruh kad tetapan, shop.env.
cat shop.env dulu untuk baca kad itu.quoted.env tulis SHOP_NAME="Kedai Kancil". Apa yang aplikasi dapat?
Ralat sebenar: variable 'SHOP_NAME ' contains whitespaces. Maksudnya: jangan letak ruang kosong di tepi tanda =.
Baris ini sesuai untuk fail env, atau tidak?
Kini anda boleh beri container tetapannya dalam satu fail.
You finished this before. Practice is always welcome!
Official docs: Docker docs: docker run --env-file · Docker docs: Environment variables in Compose
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?