dockge icon indicating copy to clipboard operation
dockge copied to clipboard

Commented out lines in compose file disappear when starting/deploying container.

Open JohnDoe-dev-spec opened this issue 2 years ago • 10 comments

⚠️ Please verify that this bug has NOT been reported before.

  • [X] I checked and didn't find similar issue

🛡️ Security Policy

Description

I have created a new stack with Dockge and commented out some lines in the YAML with #

I then start/deploy the stack and it creates successfully and refreshed the page. The compose.yaml no longer shows me the commented out line, it disappears.

I then login to the host and nano compose.yaml and i can see the commented out line there but not in Dockge.

👟 Reproduction steps

Create stack and comment out line Deploy/start stack Refresh Page

Line disappears

👀 Expected behavior

The commented out line still to appear in my compose.yaml so i can reintroduce it if i want to.

😓 Actual Behavior

Commented out line disappears from Dockge GUI

Dockge Version

1.1.1.1

💻 Operating System and Arch

DietPI Debian

🌐 Browser

Firefox/Chrome

🐋 Docker Version

Docker 24.0.7

🟩 NodeJS Version

N/A

📝 Relevant log output

No response

JohnDoe-dev-spec avatar Nov 24 '23 19:11 JohnDoe-dev-spec

Noticed this too.

cirrusflyer avatar Nov 24 '23 23:11 cirrusflyer

Need an example, I cannot reproduce. Still there after refresh.

image

louislam avatar Nov 25 '23 04:11 louislam

I can't seem to reproduce it either anymore.

It did disappear!

Close this off for now and if it happens again i will re-open with example.

Thanks!

JohnDoe-dev-spec avatar Nov 25 '23 22:11 JohnDoe-dev-spec

It's seams like that this is still an issue. Steps to reproduce:

  • Create a new compose
  • Paste:
version: "3.8"
services:
  nginxpm:
    image: jc21/nginx-proxy-manager:latest
    ports:
      - 80:80
      # test comment
      - 443:443
    volumes:
      - nginx_data:/data
      - nginx_letsencrypt:/etc/letsencrypt
    restart: unless-stopped
volumes:
  nginx_data: 
  nginx_letsencrypt: 
  • Save
  • Edit

marvint24 avatar Mar 06 '24 20:03 marvint24

I can confirm that it's still happening. The lines disappear as soon as you start editing the stack.

Edit to say that only certain comments will disappear, as the one provided in this comment. Commenting out the whole ports entry will not be affected.

andzno1 avatar Mar 15 '24 22:03 andzno1

@louislam Can we re-open this issue please? The steps given by @marvint24 also are reproduceable on my end.

mikansontap123 avatar May 19 '24 10:05 mikansontap123

Happens reliably when commenting out a label.

bpbradley avatar Jun 21 '24 04:06 bpbradley

was looking in to this because its really annoying. it happens on this parseDocument function call https://github.com/louislam/dockge/blob/109222f0248e17935db439d2db0eb421194007da/frontend/src/pages/Compose.vue#L703

it can deal with comments at the start and end of an array but not in the middle so

label:
  # comment at start of object
  - label.on.container=true
  # comment at middle of object
  - label.on.container2=false
  # comment at end of object

would remove the middle comment but the start and end ones would stay leading to the front-end displaying

label:
  # comment at start of object
  - label.on.container=true
  - label.on.container2=false
  # comment at end of object

to be clear the comment is actually there in the file until you save/deploy it again after editing its just failing at the yaml > object step to making it editable in the browser

Robonau avatar Aug 10 '24 18:08 Robonau

a work around for now is to do like so

labels:
  # comment at start of object
  - label.on.container=true
  - a # comment at middle of object
  - label.on.container2=false
  - b # comment at middle2 of object
  - c # comment at middle3 of object
  - d # comment at middle4 of object
  - label.on.container3=false
  # comment at end of object

this should work fine for both labels and environment as the a,b,c,d values are just ignored if they are not used

Robonau avatar Aug 11 '24 16:08 Robonau

I can confirm the workaround @Robonau suggested, lines which are only a comment get removed when you edit the compose. except if they are placed right below a section start or right at its end.

And comments placed to the right of a compose parameter are left untouched.

Also, upon editing the template the comments which do not get removed have their indentation changed like so (probably by design, but as they being comments I did not expect it to happen):

An saved example compose excerpt:

volumes: # to the right of section name # at beginning of section - ./data:/data # at end of section

When I edit it:

volumes: # to the right of section name (moved down and got indented to align with the existing parameter) # at beginning of section (indented to align with the existing parameter ) - ./data:/data # at end of section (indented to align with the section title)

shalafi99 avatar Aug 30 '24 19:08 shalafi99

Bumping this issue, it's definitely something I've been dealing with for many months. I've started editing most of my compose files manually via terminal so Dockge doesn't remove the comment lines leading with (#). Interestingly, after I edit the files manually, Dockge refuses to show many of the comments.

frostronic avatar Nov 28 '24 01:11 frostronic

I've added a PR which hopefully sorts this issue out, as i lost quite a bit of work from my Traefik labels when i was commenting things out (trial and error) to see what was killing one of my dockers when setting up Keycloak.

Either way, thanks for a fantastic app, I've completely moved away from Portainer now for my homelab and VPS as this is exactly what i wanted in a product; saving the endless docker compose down && docker compose up -d's when developing.

turnah avatar Dec 10 '24 18:12 turnah

I can confirm this is still an issue PS. Thanks for a great all.

rpanizzon avatar Mar 17 '25 09:03 rpanizzon

Also confirmed here. Came just to open the bug and searched to find this. I figured it would be a 'parse > rewrite' type issue. Curious, why do the 'rewrite' portion? Just to keep it standardized maybe. May I suggest two YAMLs then? compose.yaml that is actually executed by docker, and an compose-user.yaml that maintains whatever is in the editor. I haven't coded in years so I can't contribute much, at least not very quickly.

SP3NGL3R avatar Apr 09 '25 21:04 SP3NGL3R