sixeyed / diamol

Code samples for the book "Learn Docker in a Month of Lunches"
https://www.manning.com/books/learn-docker-in-a-month-of-lunches
Creative Commons Attribution Share Alike 4.0 International
496 stars 261 forks source link

Chapter 14.1 - Try It Now Exercise #1 - Incorrect Stack.yml file Syntax Produced #55

Closed brian4ko closed 1 year ago

brian4ko commented 1 year ago

Exercise Chapter 14.1 - Try It Now Exercise #1 - Page 252

Problem "docker-compose -f ./numbers/docker-compose.yml -f ./numbers/prod.yml config > stack.yml" produces an incorrect stack.yml file

Trying to run the command yields: (root) Additional property name is not allowed

Docker version Client: Cloud integration: v1.0.29 Version: 20.10.17 API version: 1.41 Go version: go1.17.11 Git commit: 100c701 Built: Mon Jun 6 23:09:02 2022 OS/Arch: windows/amd64 Context: default Experimental: true

Server: Docker Desktop 4.12.0 (85629) Engine: Version: 20.10.17 API version: 1.41 (minimum version 1.12) Go version: go1.17.11 Git commit: a89b842 Built: Mon Jun 6 23:01:23 2022 OS/Arch: linux/amd64 Experimental: true containerd: Version: 1.6.8 GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0

Code version commit 71384f8c09a8e0b3867a2c73ae09549774a21e85 (HEAD -> master, local/master) Author: Elton Stoneman elton@sixeyed.com Date: Fri Mar 5 15:43:14 2021 +0000

Additional context "docker-compose -f ./numbers/docker-compose.yml -f ./numbers/prod.yml config > stack.yml" produces an incorrect stack.yml syntax file

I resolved two initial errors in the file:

  1. unsupported Compose file version: 1.0 ---added version: "3.8" at the beginning of the file
  2. services.numbers-web.ports.0.published must be a integer ---removed quotes around the number 80 (it was flagging published: "80")

I still get the error: (root) Additional property name is not allowed

I suspect this is due to spacing/indentation and how the files were merged. However I cannot put my finger on it. Can someone spot what the error might be?

Much appreciated if anyone can help Thanks!


Original merged stack.yml produced:

name: numbers services: numbers-api: deploy: replicas: 6 resources: limits: cpus: "0.50" memory: "78643200" image: diamol/ch08-numbers-api networks: app-net: null numbers-web: deploy: mode: global resources: limits: cpus: "0.75" memory: "157286400" environment: RngApi__Url: http://numbers-api/rng image: diamol/ch08-numbers-web networks: app-net: null ports:


Docker-Compose.yml (first file)

version: "3.7"

services: numbers-api: image: diamol/ch08-numbers-api networks:


Prod.yml (Second File)

version: "3.7"

services: numbers-api: deploy: replicas: 6 resources: limits: cpus: "0.50" memory: 75M

numbers-web: ports:

networks: app-net: name: numbers-prod

brian4ko commented 1 year ago

Original post spacing got all messed up. Attached are the yml files themselves.

stack.txt docker-compose.txt prod.txt

brian4ko commented 1 year ago

Solution to this problem was:

Add "version: 3.7" at the beginning Remove the line "name: numbers" Remove the quotation marks around "80" in published port