skip to Main Content

I am trying to run the following command while setting up a dev environment in docker container & getting the above error.

./install && source $([ $SHELL = "/bin/zsh" ] && echo ~/.zshrc || echo ~/.bashrc);

Environment:

  • Docker Desktop:4.9.1 (81317)
  • Ubuntu: 20.04.4 LTS
  • OS: Windows 11 Home

enter image description here

2

Answers


  1. You are missing sudo

    sudo ./install && source $([ $SHELL = "/bin/zsh" ] && echo ~/.zshrc || echo ~/.bashrc);

    Login or Signup to reply.
  2. You can not manipulate hosts file since it is being managed by docker daemon. To prevent access problems/errors when you manipulate linux system files in docker, you can add "copy" parameter for sed command in your install script such as:

    sed -i -c ...
    

    But when you run the container, you will see the unchanged original file. You can think about applying these kind of tricks in Entrypoint or CMD command sections of Dockerfile, details are at the end.

    There are other solutions but valid only during docker build:

    1. –add-host

    Docker binary has an option "–add-host":
    https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file—add-host

    1. extraHosts

    If you are working with AWS you have directly corresponded feature "extraHosts":
    https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html

    If you need the modification persistent in container run time you only have the option to modify Entrypoint or CMD:
    https://stackoverflow.com/a/40430182/1980180

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search