Created
October 31, 2024 09:03
-
-
Save arsalanses/2f4a698c24371eebad50f95e0d91eb9c to your computer and use it in GitHub Desktop.
docker swarm config service update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -xue | |
OLD_CONFIG=$(docker service inspect service_name | jq .[].Spec.TaskTemplate.ContainerSpec.Configs[].ConfigName) | |
OLD_VERSION=${OLD_CONFIG: -2:-1} | |
NEW_VERSION=$((OLD_VERSION + 1)) | |
NEW_CONFIG=$(echo "$OLD_CONFIG" | sed "s/$OLD_VERSION/$NEW_VERSION/") | |
echo "NEW_CONFIG: $NEW_CONFIG" | |
docker config create ${NEW_CONFIG:1:-1} ./.env | |
docker service update --config-rm ${OLD_CONFIG:1:-1} --config-add source=${NEW_CONFIG:1:-1},target=/app/.env service_name | |
# docker service inspect service_name | jq .[].Spec.TaskTemplate.ContainerSpec.Configs[].ConfigName | |
# docker config rm env_config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment