Docker : please show me how to edit a file in a running container

  • hi


    I'd love a small guide on how to edit a file or files in a container that's running. Is it possible to do without having to recreate the whole container with port mappings, drive mappings etc etc?


    Oh and what's the best way of editing? I'm having some trouble finding where the files are for each individual docker....

    • Offizieller Beitrag

    Is it possible to do without having to recreate the whole container with port mappings, drive mappings etc etc?


    Docker does not permit this kind of editing. Port mapping at the end is just a netfilter (iptables) nat rule. However i've done some edit changing the restart policy for example. If you run docker inspect containername you'll get a json output with lots of information of the docker container.


    For example you can find this kind of info


    Code
    "ResolvConfPath": "/media/dd703d81-9006-411d-a256-587ac3260154/docker/containers/b6e58f504b6ddf0180bb3ba372432a47b1593ab4317d34447d61ff57dc24d50a/resolv.conf",
    
    
          "HostnamePath": "/media/dd703d81-9006-411d-a256-587ac3260154/docker/containers/b6e58f504b6ddf0180bb3ba372432a47b1593ab4317d34447d61ff57dc24d50a/hostname",
    
    
          "HostsPath": "/media/dd703d81-9006-411d-a256-587ac3260154/docker/containers/b6e58f504b6ddf0180bb3ba372432a47b1593ab4317d34447d61ff57dc24d50a/hosts",
    
    
          "LogPath": "/media/dd703d81-9006-411d-a256-587ac3260154/docker/containers/b6e58f504b6ddf0180bb3ba372432a47b1593ab4317d34447d61ff57dc24d50a/b6e58f504b6ddf0180bb3ba372432a47b1593ab4317d34447d61ff57dc24d50a-json.log


    I can change the restart policy by editing this file with the daemon OFF. So you can try and edit the mappings inside that file to try if you want, not guaranteed that i'll work BTW


    /media/dd703d81-9006-411d-a256-587ac3260154/docker/containers/b6e58f504b6ddf0180bb3ba372432a47b1593ab4317d34447d61ff57dc24d50a/hostconfig.json



    The docker plugin in version 3 has an edit feature that basically does copy the old settings, then you add the or edit settings, delete the old container and starts a new one, all in one go. Unfortunately the plugin is stalled for latest omv3 datamodels

  • thank you subzero..


    So if I want to edit say... the Rutorrent docker container and change a file in the core, then I would have to stop & delete the running container I have..
    then edit the original container which I pulled?
    if there's any update to the container.. I will loose my changes.. right?

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!