docker / docker/docker-py

/etc/hosts will be empty if set hostname in create_container

Open
#955 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

My Env

  • docker python
docker-py==1.7.0
Python 2.7.8
Client:
 Version:      1.10.1
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   9e83765
 Built:        Thu Feb 11 19:18:46 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.1
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   9e83765
 Built:        Thu Feb 11 19:18:46 2016
 OS/Arch:      linux/amd64
  • OS: CentOS Linux release 7.1.1503 (Core), 3.10.0-229.el7.x86_64 GNU/Linux

My code

create_container params:

data = {
       'image': docker_image,
       'command': None,
       'hostname': 'xxxxxxx',
       'host_config': host_config,
       ......
}

host_conf = {
            'oom_kill_disable': False,
            'privileged': False,
            'network_mode': 'none',
            'ulimits': set_limits(), # my code for limits
            'dns': ['8.8.8.8', '8.8.4.4'],
            'extra_hosts': {'xxxxxxx': '127.0.1.1'},
            'mem_limit': '32M',
            'memswap_limit': '32M',
            'read_only': False
    }

###  and I create container use 

host_config = client.create_host_config(**host_conf)
client.create_container(**data)

#### Then start it, but exit, and docker logs show below.

Outputs

sudo: unable to resolve host xxxxxxx
sudo: unable to resolve host xxxxxxx
sudo: unable to resolve host xxxxxxx
sudo: unable to resolve host xxxxxxx
[root@centos tests]# docker exec 85493efa3b65 wc -l /etc/hosts
0 /etc/hosts

and container EXIT

  • extra_hosts set but not useful

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the create_container and create_host_config entry points using hostname, network_mode='none', and extra_hosts, then reproduce the report on the stated Docker and Python versions. Inspect the resulting container's /etc/hosts and exit behavior; done means the hostname and extra_hosts entries are handled as intended instead of leaving /etc/hosts empty.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
backend, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.