Docker stack deploy not deploying the images that is being build after code changes in repo
Asked Answered
P

0

6

I have created jobs for build and deploy.

The jobs are running perfectly without no errors and the project is deployed successfully.

The problem is though the repository is changed the build is not showing up the changes when tested in the browser although the workspace is successfully pulling the latest code with changes.

Few tried solutions

  1. Made the docker image build not use the cache

  2. Made the workspace clear before starting the build

Nothing seems working. Where might have things gone wrong?

My project structure:

Project directory: Which will have all the laravel project

Dockerfile: to build the image

docker-compose.yml: To deploy the service in docker stack

I am running the service in docker stack using docker stack deploy command

I tried to delete the previously build docker stack .By naming the docker stack unique with buildID and re-create a new stack but it didn't solve either.

On trying to remove the stack and generate that again. I get these issues.

Failed to remove network 7bkf0kka11s08k3vnpfac94q8: Error response from daemon: rpc error: code = FailedPrecondition desc = network 7bkf0kka11s08k3vnpfac94q8 is in use by task lz2798yiviziufc5otzjv5y0gFailed to remove some resources from stack: smstake43
  1. Why is the docker stack not taking the updated image looks like it's due to the digest issue. How can it be solved if it is? Though the changes are pushed to Btbucket code repo the deployment is not showing changes due to it. If I completely do all the setup then only it fetches the latest codes.

This is bash scripts for build in jenkins jobs

#!/bin/sh
 
docker build -t smstake:latest .
docker stack deploy -c docker-compose.yml smstake
Pantelegraph answered 25/3, 2018 at 6:37 Comment(9)
did you have pipeline of jobs? cause you mentioned build and deploy jobs you have configured. Suggestion from my end is you are may be forgetting to build your code using docker build.Thirsty
docker build -t <dir path> . like this in your build step after pulling the latest code. You may be deploying the same image again and again.Thirsty
@SVMadhavaReddy I have build the image and have also added the remove command before building it to ensure if there exist one already. But that didn't help either.Pantelegraph
You should be push the image also to a docker registry if you have multiple nodes. Are you using a local+single manager+node?Duodenitis
yes was doing kind of that previously but I also have insecure registries created and the images is pushed and pulled from there. Checking the jenkins build jobs shows latest project but in container its passing older image. @TarunLalwaniPantelegraph
See if the utility mentioned in this github.com/moby/moby/issues/31068 helps?Duodenitis
Here is one solution i have found. Pushing and pulling from private repository than removing the stack before deploying docker stack rm <stac-name> This is working but the build fails and than pass consecutively. This is the error I am getting on fail jobs.Removing service smstake_app Removing service smstake_db Removing service smstake_phpmyadmin Removing network smstake_smstake Creating service smstake_db failed to create service smstake_db: Error response from daemon: network smstake_smstake not found Build step 'Execute shell' marked build as failure Finished: FAILUREPantelegraph
Did you try to build the dockerimage with a unique tag rather than the default latest ?Patronage
I have solved it by using sed to pass the value to the image field in the docker-compose.yml. by using some keys there based on which replace will occur. It was not accepting the variable so did so.Pantelegraph

© 2022 - 2024 — McMap. All rights reserved.