#Cannot run the command on Dagger.io (Golang)

1 messages · Page 1 of 1 (latest)

fervent bridge
#

I convert this Dockerfile step:

RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -

to Dagger Go:

WithExec([]string{"curl", "https://packages.cloud.google.com/apt/doc/apt-key.gpg",
       "|", "apt-key", "--keyring", "/usr/share/keyrings/cloud.google.gpg", "add", "-"})

But I faced the prob:

25: exec /__cacert_entrypoint.sh curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
25: [0.05s] curl: option --keyring: is unknown
25: [0.05s] curl: try 'curl --help' or 'curl --manual' for more information
25: exec /__cacert_entrypoint.sh curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - ERROR: process "/__cacert_entrypoint.sh curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -" did not complete successfully: exit code: 2
input:1: container.from.withWorkdir.withExec.withExec.withExec.withExec.withExec.withExec.withExec.withExec.withExec.withExposedPort.withEntrypoint.stdout process "/__cacert_entrypoint.sh curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -" did not complete successfully: exit code: 2

Stdout:

Stderr:
curl: option --keyring: is unknown
curl: try 'curl --help' or 'curl --manual' for more information

Could you help me check this issue?

cerulean patio
#

Hi there!

I think this might be the same issue as this one. If you want to use pipes you need a shell. Can you try to prepend everything with "sh", "-c""

WithExec([]string{"sh", "-c", "curl", "https://packages.cloud.google.com/apt/doc/apt-key.gpg",
       "|", "apt-key", "--keyring", "/usr/share/keyrings/cloud.google.gpg", "add", "-"})

#1149704911777452112 message

fervent bridge
#
25: exec /__cacert_entrypoint.sh sh -c curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
25: [0.05s] curl: try 'curl --help' or 'curl --manual' for more information
25: exec /__cacert_entrypoint.sh sh -c curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - ERROR: process "/__cacert_entrypoint.sh sh -c curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -" did not complete successfully: exit code: 2
input:1: container.from.withWorkdir.withExec.withExec.withExec.withExec.withExec.withExec.withExec.withExec.withExec.withExposedPort.withEntrypoint.stdout process "/__cacert_entrypoint.sh sh -c curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -" did not complete successfully: exit code: 2

Stdout:

Stderr:
curl: try 'curl --help' or 'curl --manual' for more information

hi @cerulean patio , it's not worked 😦

#

hi @cerulean patio , after I tried to use

     WithExec([]string{"sh", "-c", "curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -"}).

It's worked now, many thanks ^^