Skip to content

Unable to modify /etc/hosts file in a container #1951

Closed
@mohanraj-r

Description

As part of my test setup, the setup script needs to append a line to /etc/hosts

Doing sudo echo "127.0.0.1 foo.bar" >> /etc/hosts results in the following error when executed inside a container

/bin/sh: /etc/hosts: Read-only file system

Googled the error and based on a suggestion from superuser.com issued the command sudo -- sh -c "echo test >> /etc/hosts". But it results in the same error

vi /etc/hosts opens the file in read-only mode. Changing permission doesn't work as well.

bash-3.2# chmod a+w /etc/hosts
chmod: changing permissions of `/etc/hosts': Read-only file system

Any suggestions?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions