Skip to content

init: Don't require having a /etc/hosts file #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion scripts/container-only/.wkdev-init
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ process_command_line_arguments() {
try_copy_hosts_file() {

task_step "Copying /etc/hosts file from host to container..."
cp /host/etc/hosts /etc/hosts || _abort_ "Cannot copy /etc/hosts file from host to container"
if [ -f /host/etc/hosts ]; then
cp /host/etc/hosts /etc/hosts || _abort_ "Cannot copy /etc/hosts file from host to container"
else
echo "No hosts file found, creating one."
cat > /etc/hosts <<EOF
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
EOF
fi
}

try_update_apt_cache() {
Expand Down