nerdctl icon indicating copy to clipboard operation
nerdctl copied to clipboard

unsupport configs filed

Open xjdtd opened this issue 1 year ago • 5 comments

What is the problem you're trying to solve

docker-compose.yaml configs: create_db_sql: content: | CREATE DATABASE kuboard DEFAULT CHARACTER SET = 'utf8mb4' DEFAULT COLLATE = 'utf8mb4_unicode_ci'; create user 'kuboard'@'%' identified by 'kuboardpwd'; grant all privileges on kuboard.* to 'kuboard'@'%'; FLUSH PRIVILEGES;

services: db: image: swr.cn-east-2.myhuaweicloud.com/kuboard/mariadb:11.3.2-jammy environment: MARIADB_ROOT_PASSWORD: kuboardpwd MYSQL_ROOT_PASSWORD: kuboardpwd TZ: Asia/Shanghai volumes: - ./kuboard-mariadb-data:/var/lib/mysql:Z configs: - source: create_db_sql target: /docker-entrypoint-initdb.d/create_db.sql mode: 0777 networks: kuboard_v4_dev: aliases: - db kuboard: image: swr.cn-east-2.myhuaweicloud.com/kuboard/kuboard:v4 environment: - DB_DRIVER=org.mariadb.jdbc.Driver - DB_URL=jdbc:mariadb://db:3306/kuboard?serverTimezone=Asia/Shanghai - DB_USERNAME=kuboard - DB_PASSWORD=kuboardpwd ports: - '8000:80' depends_on: - db networks: kuboard_v4_dev: aliases: - kuboard

networks: kuboard_v4_dev: driver: bridge

[root@master01 v4]# ./nerdctl/bin/nerdctl compose -f docker-compose.yaml up WARN[0000] Ignoring: config create_db_sql: [Content]
FATA[0000] config "create_db_sql": lacks file path
You have new mail in /var/spool/mail/root [root@master01 v4]# ./nerdctl/bin/nerdctl --version nerdctl version 2.0.0-beta.5 You have new mail in /var/spool/mail/root

Describe the solution you'd like

want nertctl to support docker-compose.yaml like above file

Additional context

No response

xjdtd avatar Jun 17 '24 02:06 xjdtd

would you mind formatting your yaml file first?

Zheaoli avatar Jun 17 '24 12:06 Zheaoli

docker-compose.yaml.log @Zheaoli

xjdtd avatar Jun 18 '24 09:06 xjdtd

Inline here:


configs:
  create_db_sql:
    content: |
      CREATE DATABASE kuboard DEFAULT CHARACTER SET = 'utf8mb4' DEFAULT COLLATE = 'utf8mb4_unicode_ci';
      create user 'kuboard'@'%' identified by 'kuboardpwd';
      grant all privileges on kuboard.* to 'kuboard'@'%';
      FLUSH PRIVILEGES;

services:
  db:
    image: swr.cn-east-2.myhuaweicloud.com/kuboard/mariadb:11.3.2-jammy
    # image: mariadb:11.3.2-jammy  
    # swr.cn-east-2.myhuaweicloud.com/kuboard/mariadb:11.3.2-jammy 与 mariadb:11.3.2-jammy 镜像完全一致
    environment:
      MARIADB_ROOT_PASSWORD: kuboardpwd
      MYSQL_ROOT_PASSWORD: kuboardpwd
      TZ: Asia/Shanghai
    volumes:
      - ./kuboard-mariadb-data:/var/lib/mysql:Z
    configs:
      - source: create_db_sql
        target: /docker-entrypoint-initdb.d/create_db.sql
        mode: 0777
    networks:
      kuboard_v4_dev:
        aliases:
          - db
  kuboard:
    image: swr.cn-east-2.myhuaweicloud.com/kuboard/kuboard:v4
    # image: eipwork/kuboard:v4
    environment:
      - DB_DRIVER=org.mariadb.jdbc.Driver
      - DB_URL=jdbc:mariadb://db:3306/kuboard?serverTimezone=Asia/Shanghai
      - DB_USERNAME=kuboard
      - DB_PASSWORD=kuboardpwd
    ports:
      - '8000:80'
    depends_on:
      - db
    networks:
      kuboard_v4_dev:
        aliases:
          - kuboard

networks:
  kuboard_v4_dev:
    driver: bridge

I am not super familiar with compose-go or what we do for compose in here, but it seems to me that the issue is that configs does apparently not support flat content instead of a file path - https://github.com/compose-spec/compose-spec/blob/master/08-configs.md#example-2

apostasie avatar Jun 19 '24 01:06 apostasie

Hi, maintainers! I'll work on this issue, so could you assign this issue to me?

haytok avatar May 30 '25 06:05 haytok

This is a rather useful feature I use quite a bit with Docker Compose, so it would be good to see support land here too.

FWIW this section does not apply when using Configs content or environment types:

https://github.com/containerd/nerdctl/blob/2165e30feb950635f1d22becacfa5a1121412749/docs/compose.md?plain=1#L41-L44

When I share examples / advice on bug reports if the associated extra files are rather small/simple I user configs.content, and for executables set mode to enable +x without an extra step.

polarathene avatar Nov 08 '25 00:11 polarathene