forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request containers#21013 from gavinkflam/17167-compat-base…
…-hosts-file Fix Docker API compatibility with network alias
- Loading branch information
Showing
13 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
etc hosts | ||
=========== | ||
|
||
This test mounts a /etc/hosts file in the host containing an entry `foobar`, then create a container with an alias of the same hostname. | ||
|
||
Validation | ||
------------ | ||
|
||
* No /etc/hosts entries are copied from the host. There should be only one entry of the hostname, which is IP address of the alias. | ||
* The hostname is resolved to IP address of the alias. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: '3.3' | ||
|
||
services: | ||
test: | ||
image: alpine | ||
command: ["top"] | ||
hostname: foobar | ||
networks: | ||
net1: | ||
aliases: | ||
- foobar | ||
|
||
networks: | ||
net1: | ||
driver: bridge | ||
ipam: | ||
driver: default | ||
config: | ||
- subnet: 10.123.0.0/24 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
127.0.0.1 localhost | ||
127.0.0.1 foobar |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if ! is_rootless; then | ||
mount --bind $TEST_ROOTDIR/etc_hosts/hosts /etc/hosts | ||
else | ||
$PODMAN_BIN unshare mount --bind $TEST_ROOTDIR/etc_hosts/hosts /etc/hosts | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if ! is_rootless; then | ||
umount /etc/hosts | ||
else | ||
$PODMAN_BIN unshare umount /etc/hosts | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# -*- bash -*- | ||
|
||
ctr_name="etc_hosts_test_1" | ||
if [ "$TEST_FLAVOR" = "compose_v2" ]; then | ||
ctr_name="etc_hosts-test-1" | ||
fi | ||
|
||
podman exec "$ctr_name" sh -c 'grep "foobar" /etc/hosts' | ||
like "$output" "10\.123\.0\." "$testname : no entries are copied from the host" | ||
|
||
podman exec "$ctr_name" sh -c 'getent hosts foobar | awk "{print \$1}"' | ||
like "$output" "10\.123\.0\." "$testname : hostname is resolved to IP address of the alias" |
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