hackoregon / devops-17

deployment tools for Hack Oregon projects
4 stars 3 forks source link

Docker push: ERROR: An image does not exist locally with the tag #44

Closed MikeTheCanuck closed 7 years ago

MikeTheCanuck commented 7 years ago

Our project (https://github.com/hackoregon/team-budget) is using the [backend-service-pattern] code to try to deploy the container that Travis builds for us. We're using the ecs-deploy.sh script and the same build sequence (if modified to work in all local and Travis scenarios).

Problem

I'm getting the following response when running docker push "$DOCKER_REPO"/"$DEPLOY_TARGET"/"$DOCKER_IMAGE":latest:

The push refers to a repository [845828040396.dkr.ecr.us-west-2.amazonaws.com/integration/budget-service]
An image does not exist locally with the tag: 845828040396.dkr.ecr.us-west-2.amazonaws.com/integration/budget-service

Further back in the build sequence, the standard docker-compose.yml includes two instructions:

  build: .
  image: "${DOCKER_REPO}/${DEPLOY_TARGET}/${DOCKER_IMAGE}:latest" 

However, when I enable the image section and its instruction, docker-compose via TravisCI reports the following error:

 "ERROR: The Compose file is invalid because:
 "Service budget-service has both an image and build path specified. A service can either be built to image or use an existing image, not both."

Research

When I read the Docker documentation for the image section, it contradictorily says, "If the image does not exist, Compose attempts to pull it, unless you have also specified build, in which case it builds it using the specified options and tags it with the specified tag."

That should mean that build and image can coexist, but the error message I'm receiving seems to indicate they cannot coexist.

Hell, looking further at the [documentation for the build section](), it also reports, "If you specify image as well as build, then Compose names the built image with the webapp and optional tag specified in image:

build: ./dir
image: webapp:tag

So everything except my runtime experience tells me to include the image section. What am I missing?

Links

Working build (backend-service-pattern): https://travis-ci.org/hackoregon/backend-service-pattern/builds/212920258 My failing build (team-budget): https://travis-ci.org/hackoregon/team-budget/builds/213610942

MikeTheCanuck commented 7 years ago

It appears that when I omit the version option from a docker-compose file, docker-compose treats it as a version 1 file. Further, a version 1 file does not support using build together with image, so I'm now trying later versions and see what I can wrangle from the build.

MikeTheCanuck commented 7 years ago

The build failed with version: "3" and succeeded with version:"2".

I see other projects using version: "2.1" but for now we don't have any need for the extra capabilities that come with 2.1 so this seems good enough for now.

MikeTheCanuck commented 7 years ago

As of this commit and this Travis build log, I have visible confirmation that using the version: "2" option correctly allows the container image to be built and published to ECR correctly.