I need to edit a file in a Docker container. This container does not have vi or an actual editor. I cannot install anything. I don't have access to run chown either.
- Login on the Docker host
- Get the file from the container:
docker cp b28b1d60e423:/the/file/that.I.want.json .
- Get into the container and find out what is the UID/GID which you want to create the file with (use
id
) - Edit the file on the Docker host
- Copy the file back to the container:
tar -cf - that.I.want.json --mode u=+r,g=+r,o=+r --owner 1030 --group 1030 | docker cp - b28b1d60e423:/tmp