Repository navigation
Closed
Labels
Description
What is the issue?
I am simply trying to push an image to a local registry instance. I setup the instance like this:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
Note: Need to set this in docker/daemon.json:
"insecure-registries": [
"localhost:5000"
]Here is my code:
import Client, { connect } from "@dagger.io/dagger";
connect(async (client: Client) => {
const node = client.container().from('node:18');
await node.publish('localhost:5000/example-node:latest');
}, {
LogOutput: process.stdout,
});And here is the error I get:
#3 ERROR: failed to push localhost:5000/example-node:latest: failed to do request: Head "http://localhost:5000/v2/example-node/blobs/sha256:664da43398219f08e7221736ecbdacf3fd261080f913b3926fd599126943bbe6": dial tcp 127.0.0.1:5000: connect: connection refusedI can run the docker build, tag, and push manually and it will work fine:
docker pull node:18
docker tag node:18 localhost:5000/example-node:latest
docker push localhost:5000/example-node:latestLog output
ntroncoso@UALCFJPXF4MRQ quad % node --loader ts-node/esm scripts/poc-publish.mts
(node:80622) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
#1 resolve image config for docker.io/library/node:18
#1 DONE 0.4s
#2 from node:18
#2 resolve docker.io/library/node:18
file:///Users/ntroncoso/projects/work/quad/node_modules/@dagger.io/dagger/dist/api/utils.js:5
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
^
GraphQLRequestError: Error message
at file:///Users/ntroncoso/projects/work/quad/node_modules/@dagger.io/dagger/dist/api/utils.js:121:23
at Generator.throw (<anonymous>)
at rejected (file:///Users/ntroncoso/projects/work/quad/node_modules/@dagger.io/dagger/dist/api/utils.js:5:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
cause: ClientError: failed to solve: failed to push localhost:5000/example-node:latest: failed to do request: Head "http://localhost:5000/v2/example-node/blobs/sha256:664da43398219f08e7221736ecbdacf3fd261080f913b3926fd599126943bbe6": dial tcp 127.0.0.1:5000: connect: connection refused: {"response":{"data":null,"errors":[{"message":"failed to solve: failed to push localhost:5000/example-node:latest: failed to do request: Head \"http://localhost:5000/v2/example-node/blobs/sha256:664da43398219f08e7221736ecbdacf3fd261080f913b3926fd599126943bbe6\": dial tcp 127.0.0.1:5000: connect: connection refused","locations":[{"line":2,"column":52}],"path":["container","from","publish"]}],"status":200,"headers":{}},"request":{"query":"\n { container { from (address: \"node:18\") { publish (address: \"localhost:5000/example-node:latest\") }} }\n "}}
at /Users/ntroncoso/projects/work/quad/node_modules/graphql-request/src/index.ts:498:11
at step (/Users/ntroncoso/projects/work/quad/node_modules/graphql-request/dist/index.js:67:23)
at Object.next (/Users/ntroncoso/projects/work/quad/node_modules/graphql-request/dist/index.js:48:53)
at fulfilled (/Users/ntroncoso/projects/work/quad/node_modules/graphql-request/dist/index.js:39:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
response: { data: null, errors: [Array], status: 200, headers: [Headers] },
request: {
query: '\n' +
' { container { from (address: "node:18") { publish (address: "localhost:5000/example-node:latest") }} }\n' +
' ',
variables: undefined
}
},
code: 'D100',
requestContext: {
query: '\n' +
' { container { from (address: "node:18") { publish (address: "localhost:5000/example-node:latest") }} }\n' +
' ',
variables: undefined
},
response: {
data: null,
errors: [ [Object] ],
status: 200,
headers: Headers { [Symbol(map)]: [Object: null prototype] }
}
}
#2 resolve docker.io/library/node:18 0.3s done
#2 DONE 0.3s
#3 exporting to image
#3 exporting layers done
#3 exporting manifest sha256:bcc156037ef2e720cf01aa8794cf14093613e41971a5705f5ce874b016c9a15a done
#3 exporting config sha256:c426a435e799ab8d3cc4c868233d3d992ef91ba21ef69e8eaf55cd58b78a308f done
#3 pushing layers done
#3 ERROR: failed to push localhost:5000/example-node:latest: failed to do request: Head "http://localhost:5000/v2/example-node/blobs/sha256:664da43398219f08e7221736ecbdacf3fd261080f913b3926fd599126943bbe6": dial tcp 127.0.0.1:5000: connect: connection refused
------
> exporting to image:
------
Steps to reproduce
See problem description
SDK version
Node SDK 0.3.3
OS version
macOS Ventura 13.2
Activity
troncoso commentedon Feb 16, 2023
Can anyone please help? This seems pretty cut and dry with simple reproduction steps. Or maybe I'm just missing something.
sipsma commentedon Feb 25, 2023
@troncoso @noah-troncoso the
connection refusederror is due to the fact that the dagger engine runs in its own docker container and thus in a network isolated from other containers, including that registry you are spinning up. Basically, thelocalhostof the dagger engine (where the image is being pushed from) is not the samelocalhostof the registry.Depending on your goal here, if you are just trying to test things out quickly and don't mind pushing to an external service, https://ttl.sh/ is an option that we use in our docs.
If you need to run the registry on localhost, then it's still possible but a bit more annoying. After running
connectonce from the sdk, a default dagger engine is spun up in your local docker installation. You can get the name of this container by running e.g.docker ps --filter "name=^dagger-engine-*" --format '{{.Names}}'.After that, you can start up the registry container in docker in the same network namespace like this:
docker run -d -p 5000:5000 --restart=always --name registry --network container:<DAGGER ENGINE CONTAINER NAME> registry:2.-p 5000:5000, it should bedocker run -d --restart=always --name registry --network container:<DAGGER ENGINE CONTAINER NAME> registry:2.127.0.0.1instead of localhost if the registry is not configured to listen on ipv6That should allow you to push to the localhost registry.
Let us know if that works for you.
d3rp3tt3 commentedon Mar 6, 2023
Related discussion in Discord from Nic Jackson: https://discord.com/channels/707636530424053791/1081963303921799269/1081963303921799269.
I think Nic's solution would work for this case as well.
mircubed commentedon Mar 6, 2023
@troncoso did @sipsma's response help? Are you still blocked in any way?
mircubed commentedon Jun 27, 2023
I will close as completed, but please let us know if you need any additional support!