Red5d / docker-autocompose

Generate a docker-compose yaml definition from a running container
1.77k stars 197 forks source link

errore while deploying an autocompose yaml generated file #25

Closed spupuz closed 2 years ago

spupuz commented 2 years ago

If i do docker-compose up of a file generated by the autocompose i got this error:

Traceback (most recent call last): File "/usr/bin/docker-compose", line 11, in load_entry_point('docker-compose==1.21.0', 'console_scripts', 'docker-compose')() File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 71, in main command() File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 124, in perform_command project = project_from_options('.', options) File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 41, in project_from_options compatibility=options.get('--compatibility'), File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 113, in get_project config_data = config.load(config_details, compatibility) File "/usr/lib/python3/dist-packages/compose/config/config.py", line 385, in load for config_file in config_details.config_files File "/usr/lib/python3/dist-packages/compose/config/config.py", line 385, in for config_file in config_details.config_files File "/usr/lib/python3/dist-packages/compose/config/config.py", line 552, in process_config_file validate_against_config_schema(config_file) File "/usr/lib/python3/dist-packages/compose/config/validation.py", line 437, in validate_against_config_schema config_file.filename) File "/usr/lib/python3/dist-packages/compose/config/validation.py", line 498, in handle_errors error_msg = '\n'.join(format_error_func(error) for error in errors) File "/usr/lib/python3/dist-packages/compose/config/validation.py", line 498, in error_msg = '\n'.join(format_error_func(error) for error in errors) File "/usr/lib/python3/dist-packages/compose/config/validation.py", line 424, in process_config_schema_errors return handle_generic_error(error, path) File "/usr/lib/python3/dist-packages/compose/config/validation.py", line 297, in handle_generic_error config_key, error_msg = _parse_oneof_validator(error) File "/usr/lib/python3/dist-packages/compose/config/validation.py", line 385, in _parse_oneof_validator json.dumps(context.instance), File "/usr/lib/python3.7/json/init.py", line 231, in dumps return _default_encoder.encode(obj) File "/usr/lib/python3.7/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib/python3.7/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/usr/lib/python3.7/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.class.name} ' TypeError: Object of type datetime is not JSON serializable

Red5d commented 2 years ago

Can you post the compose file that's resulting in this error?

spupuz commented 2 years ago

i have also on other, could be that given to the syntax? if i do remove some stuff and refactor the networks in network_mode: bridge it works.

I suppose that portainer does not read the same syntax.

also with host itself my docker-compose up does not work. My docker compose versione here:

openmediavault root
15:00:01 Mon Aug 23
compose-backups docker-compose version
docker-compose version 1.21.0, build unknown
docker-py version: 3.4.1
CPython version: 3.7.3
OpenSSL version: OpenSSL 1.1.1d  10 Sep 2019

my yaml file

compose-backups cat speedtest-2021.08.22-22.30.02.yaml 
version: "3"
services:
  speedtest:
    cap_add:
      - AUDIT_WRITE
      - CHOWN
      - DAC_OVERRIDE
      - FOWNER
      - FSETID
      - KILL
      - MKNOD
      - NET_BIND_SERVICE
      - NET_RAW
      - SETFCAP
      - SETGID
      - SETPCAP
      - SETUID
      - SYS_CHROOT
    cap_drop:
      - AUDIT_CONTROL
      - BLOCK_SUSPEND
      - DAC_READ_SEARCH
      - IPC_LOCK
      - IPC_OWNER
      - LEASE
      - LINUX_IMMUTABLE
      - MAC_ADMIN
      - MAC_OVERRIDE
      - NET_ADMIN
      - NET_BROADCAST
      - SYSLOG
      - SYS_ADMIN
      - SYS_BOOT
      - SYS_MODULE
      - SYS_NICE
      - SYS_PACCT
      - SYS_PTRACE
      - SYS_RAWIO
      - SYS_RESOURCE
      - SYS_TIME
      - SYS_TTY_CONFIG
      - WAKE_ALARM
    container_name: speedtest
    entrypoint:
      - /init
    environment:
      - OOKLA_EULA_GDPR=true
      - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      - 'PS1=$(whoami)@$(hostname):$(pwd)\$ '
      - HOME=/root
      - TERM=xterm
      - S6_BEHAVIOUR_IF_STAGE2_FAILS=2
      - arch=x86_64
    hostname: 9ab180954da4
    image: henrywhitaker3/speedtest-tracker:latest
    ipc: private
    labels:
      build_version: 'Linuxserver.io version:- 1.18.0-r13-ls128 Build-date:- 2021-04-30T09:40:09-04:00'
      maintainer: henrywhitaker3@outlook.com
      org.opencontainers.image.authors: linuxserver.io
      org.opencontainers.image.created: 2021-04-30T09:40:09-04:00
      org.opencontainers.image.description: "[Nginx](https://nginx.org/) is a simple\
        \ webserver with php support. The config files reside in  for easy user customization."
      org.opencontainers.image.documentation: https://docs.linuxserver.io/images/docker-nginx
      org.opencontainers.image.licenses: GPL-3.0-only
      org.opencontainers.image.ref.name: 30aaee99cb98f884c0c020567a078e1472402bca
      org.opencontainers.image.revision: 30aaee99cb98f884c0c020567a078e1472402bca
      org.opencontainers.image.source: https://github.com/linuxserver/docker-nginx
      org.opencontainers.image.title: Nginx
      org.opencontainers.image.url: https://github.com/linuxserver/docker-nginx/packages
      org.opencontainers.image.vendor: linuxserver.io
      org.opencontainers.image.version: 1.18.0-r13-ls128
    logging:
      driver: json-file
      options: {}
    mac_address: 02:42:ac:11:00:0e
    networks:
      - bridge
    ports:
      - 8766:80/tcp
    restart: unless-stopped
    volumes:
      - /zfsfiles/DockerConfig/speedtest-tracker:/config
networks:
  bridge:
    external: true
marcelrv commented 2 years ago

Experienced the same. It chokes on - 'PS1=$(whoami)@$(hostname):$(pwd)\$ ' line. I did not find a way for docker-compose to accept it

Note, the same with dates in the label. docker-compose does not accept it without surrounding quotes. As for me it only happened for specific label, I added this dirty hack

    # fix some dates from causing errors
    try:
        if values['labels']['org.label-schema.build-date'] != None:
          d =  values['labels']['org.label-schema.build-date']
          values['labels']['org.label-schema.build-date']  = "'" + str(  d ) +  "'"
    except KeyError as ke:
      pass
Red5d commented 2 years ago

Should be fixed by #36