nerdctl icon indicating copy to clipboard operation
nerdctl copied to clipboard

Make the error message clearer when args `-d` is mixed with `-tty` in `nerdctl compose`

Open ayewo opened this issue 2 years ago • 2 comments

What is the problem you're trying to solve

The following compose.yaml file:

version: '3'
services:
  test-cache:
    image: "redis:3.2.10"
    ports:
      - "6379:6379"
  test-fakesmtp:
    image: munkyboy/fakesmtp
    ports:
      - "1025:25"
    tty: true
  test-node:
    image: node:slim
    depends_on:
      - test-cache
      - test-fakesmtp

works with docker-compose (version 1.25.0) but fails on nerdctl with the following error:

INFO[0000] Creating network tmp_default
INFO[0000] Ensuring image munkyboy/fakesmtp
INFO[0000] Ensuring image redis:3.2.10
INFO[0000] Ensuring image node:slim
INFO[0000] Creating container tmp_test-cache_1
INFO[0000] Creating container tmp_test-fakesmtp_1
INFO[0000] Creating container tmp_test-node_1
FATA[0001] currently StdinOpen(-i) and Tty(-t) should be same

Describe the solution you'd like

The fatal error message can be traced to lines 161-164 in composer/up_service.go:

	// FIXME
	if service.Unparsed.StdinOpen != service.Unparsed.Tty {
		return "", fmt.Errorf("currently StdinOpen(-i) and Tty(-t) should be same")
	}

Wondering if there is a way to make the error message more explicit. Something like:

"Mixing (-d) and (-tty) is not yet supported.

Since the docs already says: WIP: currently -t conflicts with -d

Additional context

Thank you for your work on this project 🙏.

ayewo avatar Jan 30 '23 21:01 ayewo

So how do you work around this? I just ran the following command:

nerdctl compose up -d --address /var/run/docker/containerd/containerd.sock

and got the same error as the OP.

BTW, it wouldn't run at all without the --address /var/run/docker/containerd/containerd.sock part either:

cannot access containerd socket "/run/k3s/containerd/containerd.sock" (hint: try running with `--address /var/run/docker/containerd/containerd.sock` to connect to Docker-managed containerd): no such file or directory

pfconrey avatar Oct 03 '24 13:10 pfconrey

So how do you work around this? I just ran the following command:

nerdctl compose up -d --address /var/run/docker/containerd/containerd.sock

Add stdin_open: true to the service definition?

BTW, it wouldn't run at all without the --address /var/run/docker/containerd/containerd.sock part either:

cannot access containerd socket "/run/k3s/containerd/containerd.sock" (hint: try running with `--address /var/run/docker/containerd/containerd.sock` to connect to Docker-managed containerd): no such file or directory

Can you open a separate ticket for that with information about how you installed containerd, and generally what your environment is? Thanks.

apostasie avatar Oct 03 '24 18:10 apostasie

Summary, for those who just want things to work...

if you have:

tty: true

you need to make it:

tty: true
stdin_open: true

You can't have one without the other.

gerrywastaken avatar Nov 19 '24 16:11 gerrywastaken