Skip to content

cli/command/container: --use-api-socket: don't write empty credentials - #6018

Merged
vvoland merged 1 commit into
docker:masterfrom
thaJeztah:use_api_socket_no_empty
Apr 17, 2025
Merged

cli/command/container: --use-api-socket: don't write empty credentials#6018
vvoland merged 1 commit into
docker:masterfrom
thaJeztah:use_api_socket_no_empty

Conversation

@thaJeztah

@thaJeztahthaJeztah commented Apr 17, 2025

Copy link
Copy Markdown
Member

Before this patch, a valid, but empty set of credentials would still
write a config-file to the container and set DOCKER_CONFIG:

mkdir -p tmpConfig
export DOCKER_CONFIG=$PWD/tmpConfig
echo'{}'>"${DOCKER_CONFIG}/config.json"
docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.json
{
"auths": {}
}
echo'{"auths": {}}'>"${DOCKER_CONFIG}/config.json"
docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.json
{
"auths": {}
}
echo'{"auths": {"https://index.docker.io/v1/": {"auth": "am9lam9lOmhlbGxv"}}}'>"${DOCKER_CONFIG}/config.json"
docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "am9lam9lOmhlbGxv"
}
}
}

With this patch, the DOCKER_CONFIG env-var and config-file are only created
if we have credentials to set;

mkdir -p tmpConfig
export DOCKER_CONFIG=$PWD/tmpConfig
echo'{}'>"${DOCKER_CONFIG}/config.json"
docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.json
cat: can't open '/run/secrets/docker/config.json': No such file or directoryecho '{"auths": {}}' > "${DOCKER_CONFIG}/config.json"docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.jsoncat: can't open '/run/secrets/docker/config.json': No such file or directory
echo'{"auths": {"https://index.docker.io/v1/": {"auth": "am9lam9lOmhlbGxv"}}}'>"${DOCKER_CONFIG}/config.json"
docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "am9lam9lOmhlbGxv"
}
}
}

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

Before this patch, a valid, but empty set of credentials would still
write a config-file to the container and set `DOCKER_CONFIG`:
mkdir -p tmpConfig
export DOCKER_CONFIG=$PWD/tmpConfig
echo '{}' > "${DOCKER_CONFIG}/config.json"
docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.json
{
"auths": {}
}
echo '{"auths": {}}' > "${DOCKER_CONFIG}/config.json"
docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.json
{
"auths": {}
}
echo '{"auths": {"https://index.docker.io/v1/": {"auth": "am9lam9lOmhlbGxv"}}}' > "${DOCKER_CONFIG}/config.json"
docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "am9lam9lOmhlbGxv"
}
}
}
With this patch, the `DOCKER_CONFIG` env-var and config-file are only created
if we have credentials to set;
mkdir -p tmpConfig
export DOCKER_CONFIG=$PWD/tmpConfig
echo '{}' > "${DOCKER_CONFIG}/config.json"
docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.json
cat: can't open '/run/secrets/docker/config.json': No such file or directory
echo '{"auths": {}}' > "${DOCKER_CONFIG}/config.json"
docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.json
cat: can't open '/run/secrets/docker/config.json': No such file or directory
echo '{"auths": {"https://index.docker.io/v1/": {"auth": "am9lam9lOmhlbGxv"}}}' > "${DOCKER_CONFIG}/config.json"
docker run --rm --use-api-socket alpine cat /run/secrets/docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "am9lam9lOmhlbGxv"
}
}
}
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
thaJeztahforce-pushed the use_api_socket_no_empty branch from 4392009 to 711fcaeCompareApril 17, 2025 09:36
@codecov-commenter

codecov-commenter commented Apr 17, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
cli/command/container/create.go0.00%6 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@vvolandvvoland modified the milestones: 28.1.1, 28.1.0Apr 17, 2025
@thaJeztah

Copy link
Copy Markdown
MemberAuthor

@Benehiko PTAL 🤗

@vvoland
vvoland merged commit 4d8c241 into docker:masterApr 17, 2025
@thaJeztah
thaJeztah deleted the use_api_socket_no_empty branch April 17, 2025 10:34
@thaJeztahthaJeztah self-assigned this May 16, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@thaJeztah@codecov-commenter@vvoland