I'm trying to build and push a docker image to a l...
# general
c
I'm trying to build and push a docker image to a local docker repository. I've started off with the example here: https://blog.pulumi.com/program-kubernetes-with-11-cloud-native-pulumi-pearls#8__Build_and_Deploy_Container_Images_A_longside_Configuration_Updates_322 I've changed the server to
127.0.0.1:5000
. It seems to login correctly with the credentials, but when it tries to push the built image, it seems like it's not passing on the servername to the docker push commands.
Copy code
const myAppDocker = new docker.Image("myapp", {
    build: {
      context: '../',
      dockerfile: '../docker/myapp/Dockerfile'
    },
    imageName: "myapp",
    registry: {
      server: "127.0.0.1:5000",
      username: config.require("dockerUsername"),
      password: config.require("dockerPassword")
    },
});
Copy code
error: Error: 'docker push myapp:f61cb689da...' failed with exit code 1
    The push refers to repository [<http://docker.io/library/myapp|docker.io/library/myapp>]
m
This definitely sounds like it could be a bug on our end. cc @lemon-spoon-91807 @creamy-potato-29402
l
Looking 🙂
so the way this is trying to work is that we use the 'registry' object for the "docker login" call
(which, given any previous error message) seems to have worked properly.
it's unclear ot me how docker is intended to be used at this point (and i'll have to lookup some docs)
my intuition on things was that once logged in, pushes and whatnot would implicitly be targeting that registry.
can you include more of the logs @cold-train-5848? When our docker steps fail, we should be printing out more stuff. was anything else printed for you? Thanks!
ok. i see the issue
we pass the 'imageName' ("myapp" in your example) as the repositoryUrl that we pass along all the way up to doing the push.
i think what might work is to do:
Copy code
const myAppDocker = new docker.Image("myapp", {
    build: {
      context: '../',
      dockerfile: '../docker/myapp/Dockerfile'
    },
    localImageName: "myapp",
    imageName: "your repo url here",
    registry: {
      server: "127.0.0.1:5000",
      username: config.require("dockerUsername"),
      password: config.require("dockerPassword")
    },
});
The docs also seem to back this up:
Copy code
/**
     * The qualified image name that will be pushed to the remote registry.  Must be a supported image name for the
     * target registry user.
     */
    imageName: pulumi.Input<string>;
@cold-train-5848 let me know if this is enough information for you to work off of. thanks! 🙂
c
@lemon-spoon-91807, yes, that worked, thanks!
Copy code
const myAppDocker = new docker.Image("myapp", {
    build: {
      context: '../',
      dockerfile: '../docker/myapp/Dockerfile'
    },
    localImageName: "myapp",
    imageName: "127.0.0.1:5000/myapp",
    registry: {
      server: "127.0.0.1:5000",
      username: config.require("dockerUsername"),
      password: config.require("dockerPassword")
    },
});
l
oh good. Glad to hear it!