[BUG] docker_network.present does not detect hostname change
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
I have docker_network.present state and changing the hostname is not detected and container is not recreated.
Setup
Please be as specific as possible and give set-up details.
- on-prem machine
- VM (Virtualbox, KVM, etc. please specify)
- VM running on a cloud service, please be explicit and add details
- container (Kubernetes, Docker, containerd, etc. please specify)
- or a combination, please be explicit
- jails if it is FreeBSD
- classic packaging
- onedir packaging
- used bootstrap to install
Steps to Reproduce the behavior
I have Docker installed on target server:
dpkg -l | grep docker on target server:
docker.io 24.0.5-0ubuntu1~22.04.1
python3-docker 5.0.3-1
lsb_release -a on target server:
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
I use the following state:
test:
docker_container.running:
- image: alpine:3.18
- command: sleep infinity
When I then check its hostname it is a random one (as expected, see #66409):
$ docker inspect --format '{{.Config.Hostname}}' test
2923c0067fa9
Then I change the state to:
test:
docker_container.running:
- image: alpine:3.18
- command: sleep infinity
- hostname: test
I call state.highstate again, and nothing is reported changed by Salt. Running the command again:
$ docker inspect --format '{{.Config.Hostname}}' test
2923c0067fa9
Expected behavior
After state change I expect the output to be:
$ docker inspect --format '{{.Config.Hostname}}' test
test
Versions Report
salt --versions-report
Salt Version:
Salt: 3007.0
Python Version:
Python: 3.8.10 (default, Nov 22 2023, 10:22:35)
Dependency Versions:
cffi: 1.16.0
cherrypy: unknown
dateutil: 2.9.0.post0
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.3
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.8
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 24.0
pycparser: 2.22
pycrypto: Not Installed
pycryptodome: 3.20.0
pygit2: Not Installed
python-gnupg: 0.5.2
PyYAML: 6.0.1
PyZMQ: 26.0.0
relenv: Not Installed
smmap: Not Installed
timelib: 0.3.0
Tornado: 6.4
ZMQ: 4.3.5
Salt Package Information:
Package Type: Not Installed
System Versions:
dist: ubuntu 20.04.6 focal
locale: utf-8
machine: x86_64
release: 5.15.0-101-generic
system: Linux
version: Ubuntu 20.04.6 focal
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the docker_container.running state entry point and reproduce the change with state.highstate, checking the result with docker inspect. Trace how the hostname in the state is compared with the container configuration; done means a hostname change is detected and the container reaches the requested hostname.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100