I'm approaching to Docker. I created an image debootstraping Debian Jessie and I want to add the contrib
section to APT sources file.
/etc/apt/sources.list
contents are:
$ docker run some/image cat /etc/apt/sources.list
deb http://debian.fastweb.it/debian jessie main
deb http://debian.fastweb.it/debian jessie-updates main
deb http://security.debian.org/ jessie/updates main
I want them to be:
deb http://debian.fastweb.it/debian jessie main contrib
deb http://debian.fastweb.it/debian jessie-updates main contrib
deb http://security.debian.org/ jessie/updates main contrib
So I ran this command:
docker run some/image sed -i 's/main/main contrib/g' /etc/apt/sources.list
Which exits without errors; but it doesn't update /etc/apt/sources.list
contents:
$ docker run some/image cat /etc/apt/sources.list
deb http://debian.fastweb.it/debian jessie main
deb http://debian.fastweb.it/debian jessie-updates main
deb http://security.debian.org/ jessie/updates main
You did not change the image. You started a container, based on the image. Then you ran your sed command and changed the file contents. Check docker ps -a
to see the id of the container that just closed. If you use docker cp
to extract your file you should see that it was changed as expected (assuming your sed command was ok).
You could also create a Dockerfile
FROM some/image
RUN sed -i 's/main/main contrib/g' /etc/apt/sources.list
# this command is just temporary, you probably are going to do something else
CMD cat /etc/apt/sources.list
and run the new image docker run some/new-image
to get the expected output.
Conclusion - you probably want to do run your sed command in the original images Dockerfile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With