Search code examples
dockerdocker-volume

Can't Delete file created via Docker


I used a docker image to run a program on our school's server using this command.

 docker run -t -i -v /target/new_directory 990210oliver/mycc.docker:v1 /bin/bash

After I ran it it created a firectory on my account called new_directory. Now I don't have permissions to delete or modify the files.

How do I remove this directory?


Solution

  • Change the owner of all the files on the directory to your used ID within the container running as root, then exit the container and remove the directory.

    docker run --rm -v /target/new_directory 990210oliver/mycc.docker:v1 chown -R $(id -un):$(id -un) /target/new_directory
    exit
    rm -rf $HOME/new_directory