1 |
On second thought I put in the —hostname flags, to make it clearer. Before |
2 |
it was a digest from the container-id, which was not telling in the example… |
3 |
|
4 |
$ docker run -d -v /etc/ --name host1 --hostname host1 ubuntu tail -f /dev/null |
5 |
6a85473421368051efec9b6f55991a5c3b4150c575a0724695cdad99f7a26e06 |
6 |
$ docker run -ti --volumes-from host1 --name host2 --hostname host2 ubuntu bash |
7 |
root@host2:/# cat /etc/hostname |
8 |
host2 |
9 |
root@host2:/# |
10 |
|
11 |
Cheers |
12 |
Christian |
13 |
|
14 |
|
15 |
|
16 |
On 24 August 2016 at 08:52:15, Christian Kniep (ckniep@××××××.com) wrote: |
17 |
|
18 |
Hey there, |
19 |
|
20 |
as for the /etc/hostname when sharing /etc/ as a volume… This ain’t a |
21 |
problem as /etc/hostname is taken care of by the docker-engine (in previous |
22 |
versions they used it to discover other hosts). |
23 |
|
24 |
As you can see in the snippet below, /etc/hostname is local, while it is |
25 |
possible to create a file test in /etc/, which is also present in the |
26 |
container I mounted the volumes from. |
27 |
|
28 |
$ docker run -d -v /etc/ --name host1 ubuntu tail -f /dev/null |
29 |
3f90929cc4b761096b600d5e2b02c61ec2e26ba74167a71b2da73d28d2274dba |
30 |
$ docker run -ti --volumes-from host1 --name host2 ubuntu bash |
31 |
root@dd0167aec38e:/# cat /etc/hostname |
32 |
dd0167aec38e |
33 |
root@dd0167aec38e:/# echo "huhu" > /etc/test |
34 |
root@dd0167aec38e:/# exit |
35 |
$ docker exec host1 cat /etc/test |
36 |
|
37 |
To me the /etc/hostname problem is just to make Gentoo play nice among |
38 |
other distros. As described below, this is (IMHO) a sound solution to |
39 |
propagate the underlying hostname to the containers. |
40 |
|
41 |
Cheers Christian |
42 |
|
43 |
On 23 August 2016 at 23:22:44, William Hubbs (williamh@g.o) wrote: |
44 |
|
45 |
On Tue, Aug 23, 2016 at 04:25:30PM -0400, Rich Freeman wrote: |
46 |
> On Tue, Aug 23, 2016 at 3:57 PM, William Hubbs <williamh@g.o> |
47 |
wrote: |
48 |
> > |
49 |
> > I am planning to change the logic in /etc/init.d/hostname so that if |
50 |
> > /etc/hostname exists, the first word out of that file will be used as |
51 |
> > the hostname rather than any setting in /etc/conf.d/hostname. If you |
52 |
> > don't want /etc/hostname, just don't create it and the settings from |
53 |
> > /etc/conf.d/hostname will still be used. |
54 |
> > |
55 |
> |
56 |
> Keep in mind that this is potentially problematic for a few reasons: |
57 |
> |
58 |
> 1. The hostname could change after openrc is done setting it. If it |
59 |
> does, a program that reads /etc/hostname won't get the real hostname. |
60 |
|
61 |
This is also true for /etc/conf.d/hostname, so I don't see the problem |
62 |
here. |
63 |
|
64 |
> 2. You could have a situation where multiple containers use the same |
65 |
> /etc. Obviously in this situation you wouldn't want to store the |
66 |
> hostname anywhere in /etc unless you wanted them to all have the same |
67 |
> hostname. It would be better to obtain it from dhcp, or to have it |
68 |
> set before init is run during initialization. |
69 |
|
70 |
|
71 |
/etc/init.d/hostname doesn't run inside containers, so this is not |
72 |
relevant. |
73 |
|
74 |
> The main danger is people not thinking of all the scenarios. I'm not |
75 |
> quite sure why we even need /etc/hostname now given these issues and |
76 |
> the fact that we've apparently gotten along for a long time without |
77 |
> it. Have we ever gotten around to making /etc/mtab a symlink yet? I |
78 |
> know it wasn't for a long time. It seems like we are moving away from |
79 |
> container support when we should be moving towards it if anything... |
80 |
|
81 |
Container support is controlled by the keyword line in dependencies. |
82 |
OpenRC can detect most containers, so if you put the proper keywords on |
83 |
that line and RC_SYS is set correctly or the container is autodetected |
84 |
properly, openrc will not run the scripts that it shouldn't run in the |
85 |
container. |
86 |
|
87 |
Yes, /etc/mtab is a symlink by default now; that was taken care of a |
88 |
while back. |
89 |
|
90 |
William |