Docker sed: cannot rename /etc/sedl8ySxL: Device or resource busy

    • Josh
    • June 7th, 2017

    Unfortunately this didn’t help me, but the site header graphics gave me a good chuckle in the middle of me banging my head against a wall.

  1. Hi,

    cp -f ~/hosts.new /etc/hosts
    does fail: cp: can’t create ‘/etc/hosts’: File exists

    I’m however able to solve that issue thanks to the following command:
    echo “$(cat ~/hosts.new)” > /etc/hosts

    Best regards

    • Gabriel Fernandez
    • August 22nd, 2017

    Solved my problems. Thank you
    It’s worth noting that this must be done only on ENTRYPOINT or CMD, or yet manually running an exec command. It should not work in a RUN clause, since Docker will rewrite /etc/hosts in every layer it creates in your dockerfile.

  2. Just `sed -i` with `-c` option

    -c, –copy

    use copy instead of rename when shuffling files in -i mode

  3. Hello!

    Thank you for this fix.
    It works with Laradock.

    By the way, the cool header caught me off guard.


    • a1is3n
    • September 24th, 2021

    Thanks a lot.

  1. No trackbacks yet.