3

I've just created my first docker container and it runs successfully. My problem now is that I can't access the folder where they are stored by default

/var/lib/docker/containers

It keeps throwing the error

can't cd to containers

Dave
  • 3,280
  • 2
  • 22
  • 40
Danny
  • 75
  • 1
  • 2
  • 8

1 Answers1

7

You need root to access it:

sudo ls /var/lib/docker/containers/

Without root access:

docker@boot2docker:/c/Users/VonC/prog/b2d$ cd /var/lib/docker/containers
-sh: cd: can't cd to /var/lib/docker/containers

So this would work:

docker@boot2docker:/c/Users/VonC/prog/b2d$ sudo su -
Boot2Docker version 1.6.0, build master : a270c71 - Thu Apr 16 19:50:36 UTC 2015
Docker version 1.6.0, build 4749651
root@boot2docker:~# cd /var/lib/docker/containers/
root@boot2docker:/mnt/sda1/var/lib/docker/containers#
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • That works perfectly thanks! One more question, how do I export a container to use on another machine? Does that other (windows) machine need boot2docker installed in order to run that container? – Danny Apr 28 '15 at 10:33
  • @Danny You don't export container, but images. And yes, the other machine would need a recent Linux to run Docker containers, so for Windows, that would be boot2docker: http://stackoverflow.com/a/29303930/6309 – VonC Apr 28 '15 at 10:36
  • You should explore /var/lib/docker, depending upon your storage driver, you will find them in /var/lib/docker/aufs or var/lib/docker/devicemapper – user2915097 Apr 28 '15 at 11:26
  • @Danny you export images: you can archive an image as a tar and copy it that way (`docker export`: https://docs.docker.com/reference/commandline/cli/#export) – VonC Apr 28 '15 at 12:30
  • @Danny a more sophisticated solution would involve a private image repo: http://blog.octo.com/en/docker-registry-first-steps/ – VonC Apr 28 '15 at 12:48
  • Shouldn't there be some sort of usermod way to allow the user to access this content? – tblev Dec 17 '21 at 20:31
  • 1
    @tblev 6 years later, I still have to use `sudo` to access most parts of `/var/lib/docker`. – VonC Dec 17 '21 at 20:45
  • A cool way I've found is to use `docker logs `. It gives you the latest logs. I wonder if you could tail it this way though.. – tblev Dec 22 '21 at 17:19
  • [`docker logs --tail `](https://docs.docker.com/engine/reference/commandline/logs/) would tail the logs of a container indeed. – VonC Dec 22 '21 at 21:20