Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set podman image storage location #1916

Closed
abitrolly opened this issue Dec 2, 2018 · 35 comments
Closed

set podman image storage location #1916

abitrolly opened this issue Dec 2, 2018 · 35 comments
Assignees
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@abitrolly
Copy link
Contributor

[//]: # kind feature

or, rather, support request.

My root is mounted at SSD for speed, and so does my home. However, I am not rich, so SSD is small, and now I want more space. First I want to move images to another disk, and if that won't help, move containers as well.

I found podman info, which printed some useful info at the end.

...
store:
  ContainerStore:
    number: 3
  GraphDriverName: vfs
  GraphOptions: []
  GraphRoot: /home/anatoli/.local/share/containers/storage
  GraphStatus: {}
  ImageStore:
    number: 1
  RunRoot: /run/user/1000/run

The path /home/anatoli/.local/share/containers/storage is 6.3G, and there is only one image 745Mb in size there.

✗ podman images -a
REPOSITORY                 TAG     IMAGE ID       CREATED        SIZE
docker.io/library/golang   1.9.4   a6c306bd0b2f   8 months ago   754MB
✗ du -hs  ~/.local/share/containers/storage
6.3G	/home/anatoli/.local/share/containers/storage

I don't see how can I move images to the other place, because vfs-images contains only meta information and vfs hosts only hash dirs.

6.3G	/home/anatoli/.local/share/containers/storage/vfs
132K	/home/anatoli/.local/share/containers/storage/vfs-containers
28K	/home/anatoli/.local/share/containers/storage/vfs-images
1.8M	/home/anatoli/.local/share/containers/storage/vfs-layers

Is there a setting that I can change to store images in a separate dir?

Output of podman version:

Version:       0.10.1.3
Go Version:    go1.10.4
OS/Arch:       linux/amd64
@mheon
Copy link
Member

mheon commented Dec 2, 2018 via email

@abitrolly
Copy link
Contributor Author

Sounds like podman doesn't support changing image storage location with a simple user setting. Does that qualify for a future request? Having an option in ~/.config/containers/storage.conf- ImageStore.location = /data/podman-image.

@mheon
Copy link
Member

mheon commented Dec 2, 2018

We are moving over to creating the file by default, with the correct settings (so you'll only need to swap the one setting). That should be out in our next release (hopefully tomorrow). If you're looking for a way to just swap image storage, though, I don't think that's possible as of now - we storage images and containers in the same place as part of the architecture of containers/storage. We might be able to split that, but for now both must be in the same place.

@abitrolly
Copy link
Contributor Author

Let me know what should I do when it is released. I guess removing podman, cleaning up config files and then reinstalling it again to create the config in my home dir? Then I will be able to edit it to set storate location.

@rhatdan
Copy link
Member

rhatdan commented Dec 3, 2018

SImpler fix would be to setup a bind mount
cp -R ~/.local/share/containers /data
rm -rf ~/.local/share/containers
mkdir ~/.local/share/containers
mount -o bind /data/containers ~/.local/share/containers

@clebergnu
Copy link
Contributor

+1 for the file based configuration of the storage location.

@rhatdan
Copy link
Member

rhatdan commented Dec 12, 2018

With podman 0.12.1.1 It should generate ~/.lcontig/containers/storage.conf
This file can be edited to point at /data/containers.

@mheon
Copy link
Member

mheon commented Dec 12, 2018

~/.config/containers/storage.conf to be clear

@abitrolly
Copy link
Contributor Author

➜  ~ rm -rf ~/.local/share/containers
➜  ~ rm -rf ~/.config/containers
➜  ~ sudo dnf --enablerepo=updates-testing install podman
...
podman                            x86_64       0.12.1.1-1.git66d3499.fc28        updates-testing       7.0 M
➜  ~ cat .config/containers/storage.conf 
[storage]
  driver = "vfs"
  runroot = "/run/user/1000"
  graphroot = "/home/anatoli/.local/share/containers/storage"
  [storage.options]
    mount_program = ""

@mheon
Copy link
Member

mheon commented Dec 13, 2018

It's not really clear from the generated file, but graphroot there is container and image storage

@clebergnu
Copy link
Contributor

@mheon you're right that it's not clear... not sure if the generated ~/.config/containers/storage.conf can include comment/documentation. That alone would help a lot.

@mheon
Copy link
Member

mheon commented Dec 13, 2018

It could, but it would be a fair bit of effort on our end (straight TOML generation to templated output). Probably worth it, though.

@abitrolly
Copy link
Contributor Author

Looks like Tom doesn't count comments as a feature - toml-lang/toml#284

@rhatdan
Copy link
Member

rhatdan commented Mar 8, 2019

@giuseppe I think your code is doing this, could you take a look.

@abitrolly
Copy link
Contributor Author

How often does podman touch storage folder while sitting in a background and not starting other containers? Is there a way to measure that?

@giuseppe
Copy link
Member

You'd need to change both storage.conf and libpod.conf to update the path to static dir.

Migration is currently blocked by us validating the config file settings with the db.

It should work if you start with a fresh storage

@abitrolly
Copy link
Contributor Author

If migration is impossible, then the only way is remove podman, then edit files

vim $HOME/.config/containers/libpod.conf
# volume_path = "$HOME/.local/share/containers/storage/volumes"
# static_dir = "$HOME/.local/share/containers/storage/libpod"
vim $HOME/.config/containers/storage.conf
# [storage]
#   graphroot = "$HOME/.local/share/containers/storage"

, kill $HOME/.local/share/containers, and install podman again.

@giuseppe
Copy link
Member

why do you need to remove podman and install it again?

@rhatdan
Copy link
Member

rhatdan commented Apr 13, 2019

I believe this is no longer an issue.

@rhatdan rhatdan closed this as completed Apr 13, 2019
@sunshine69
Copy link

Not sure if anything wrong with my setup as of now I seems to hit this bug. The only way to make it work is using mount bind.

as long as I have .config/containers/storage.conf with all correct settings podman always says:
Error: mkdir /var/run/containers: permission denied

podman is in fedora 33,

podman --version
podman version 2.2.1

the only thing it works by remove the custom config and then copy the storage over the other directory and empty the original one, mount bind two dir together.

Should we re-open this issue?

@giuseppe
Copy link
Member

giuseppe commented Mar 1, 2021

how does the .config/containers/storage.conf file look like?

@locaIhost
Copy link

The same situation, but tune in /etc/containers/storage.conf
and no one bothers to do symlink.

@sunshine69
Copy link

how does the .config/containers/storage.conf file look like?

I have to remove it. But when I have issues described the content is as basic

[storage]
driver = "overlay"
runroot = "/mnt/portdata/containers/stevek/storage-runroot"
graphroot = "/mnt/portdata/containers/stevek/storage"
rootless_storage_path = "/mnt/portdata/containers/stevek/storage"

@locaIhost
Copy link

locaIhost commented Mar 7, 2021

how does the .config/containers/storage.conf file look like?

I have to remove it. But when I have issues described the content is as basic

[storage]
driver = "overlay"
runroot = "/mnt/portdata/containers/stevek/storage-runroot"
graphroot = "/mnt/portdata/containers/stevek/storage"
rootless_storage_path = "/mnt/portdata/containers/stevek/storage"

Well, you have many solutions

  1. Request a list of package file from the repository.
    rpm -vlq podman |grep ".conf"
  2. Make a choice of a package dependency, go over them ;)
    yum deplist podman |grep containers-common
  3. Look it.
    rpm -qdf /usr/bin/podman
    4.Significant!
    https://github.com/containers/podman/blob/master/vendor/github.com/containers/storage/storage.conf
  4. My default? ok
    https://gist.github.com/locaIhost/7404c69e22e18c0a4a58b9cd41136934
    ......... and
    man containers-storage.conf
    .........
    If that write - happy to answer:: Give a Certification RHCSA Discount on Women's Day!

@Bill0412
Copy link

Bill0412 commented Aug 18, 2022

Thanks, this saves my life!

I don't have root permission on the machine. Solved the problem by using the following steps:

  1. mkdir -p ~/.config/containers/
  2. cp /etc/containers/storage.conf ~/.config/containers
  3. Change runroot, graphroot to directories inside /run/user/$UID, you don't have to create these directories manually, podman will create them for you.
  4. export TMPDIR="/run/user/$UID/podman-tmp", maybe you can add this to your ~/.bashrc.
  5. mkdir -p $TMPDIR.

referenced this: #5412

@YevheniiPokhvalii
Copy link

My /etc/containers/storage.conf in Ubuntu WSL2 is empty.

@rhatdan
Copy link
Member

rhatdan commented Sep 29, 2022

Check /usr/share/containers/storage.conf

@YevheniiPokhvalii
Copy link

Check /usr/share/containers/storage.conf

No such file

@rhatdan
Copy link
Member

rhatdan commented Sep 29, 2022

Here is mine on Fedora.
storage.conf

@RichardFevrier
Copy link

RichardFevrier commented Nov 22, 2022

@giuseppe can you summarize the full process with docker support please?
Let's take for example the path /var/mnt/data/containers/storage as a target.
What folders/files to create/update? (storage.conf, libpod.conf, etc...)
What should we update in those files? (driver, runroot, graphroot, rootless_storage_path, etc...)
Thank you a lot 🙏

@rhatdan
Copy link
Member

rhatdan commented Nov 22, 2022

It is only storage.conf, you should never do anything with libpod.conf Remove it if you have on on your system.

graphroot is used to change the system storage directories for images and containers.
rootless_storage_path will override the default location for rootless users ~/.local/share/containers/

No need to update driver or runroot.

@RichardFevrier
Copy link

RichardFevrier commented Nov 23, 2022

Thanks @rhatdan
Can you update your answer (to keep it simple for anyone who's looking for a concise solution) for the case of someone already having containers. (from toolbox create, docker-compose up, etc...)
Can we simply move them? (the whole graphroot directory)
Should we recreate them?
Should we stop the systemd service(s) first? (podman-auto-update.service, podman-restart.service, podman.service, etc...)
How to check that our configuration is well applied? (sudo podman info)

@YevheniiPokhvalii
Copy link

YevheniiPokhvalii commented Nov 23, 2022

If you want to copy your images from docker to podman, I was only advised this solution: #16020

docker save IMAGE | podman load

I'm not sure for containers, but I guess, you could use something like

docker export <CONTAINER ID> | podman import - some-name:latest

@rhatdan
Copy link
Member

rhatdan commented Nov 29, 2022

I would prefer this hack.

# docker images --format docker-daemon:{{.Repository}}:{{.Tag}} | grep -v none  | xargs podman pull

See

# podman images
REPOSITORY  TAG         IMAGE ID    CREATED     SIZE
# docker images
REPOSITORY                              TAG       IMAGE ID       CREATED         SIZE
<none>                                  <none>    cf88db92256c   4 weeks ago     5.59MB
<none>                                  <none>    0a793d27c5b7   4 weeks ago     5.59MB
<none>                                  <none>    aa3749da95de   4 weeks ago     5.59MB
<none>                                  <none>    63d102f81adb   2 months ago    5.59MB
nginx                                   latest    670dcc86b69d   4 months ago    142MB
<none>                                  <none>    a0d5654bf697   5 months ago    5.59MB
<none>                                  <none>    fa94027fbe29   5 months ago    5.59MB
<none>                                  <none>    810085503773   6 months ago    5.59MB
<none>                                  <none>    2a9b6aeb963c   8 months ago    153MB
<none>                                  <none>    0022b42cdf0d   8 months ago    1.38GB
i386/alpine                             edge      c9930b809cba   8 months ago    5.46MB
registry.access.redhat.com/ubi8-micro   latest    a4b6df2ac2df   10 months ago   36.5MB
fedora                                  latest    b78af7a83692   12 months ago   153MB
alpine                                  latest    c059bfaa849c   12 months ago   5.59MB
# docker images --format docker-daemon:{{.Repository}}:{{.Tag}} | grep -v none  | xargs podman pull
Getting image source signatures
Copying blob abc66ad258e9 done  
Copying blob f931b78377da done  
Copying blob d7783033d823 done  
Copying blob 43b3c4e3001c done  
Copying blob 4553dc754574 done  
Copying blob 243243243ee2 done  
Copying config 670dcc86b6 done  
Writing manifest to image destination
Storing signatures
670dcc86b69df89a9d5a9e1a7ae5b8f67619c1c74e19de8a35f57d6c06505fd4
Getting image source signatures
Copying blob 8329b0e13e56 done  
Copying config c9930b809c done  
Writing manifest to image destination
Storing signatures
WARNING: image platform ({386 linux  [] }) does not match the expected platform ({amd64 linux  [] })
c9930b809cbaef2f8784f3b8ed929caa8e95a944815bf91721cb050fe9779613
Getting image source signatures
Copying blob fe7a061dd3ad done  
Copying blob 5f70bf18a086 done  
Copying config a4b6df2ac2 done  
Writing manifest to image destination
Storing signatures
a4b6df2ac2dfb315a4edf1c62f4e44c466ca3ad81d8acc4beba31b07daa9fe77
Getting image source signatures
Copying blob 389adea752cd done  
Copying config b78af7a836 done  
Writing manifest to image destination
Storing signatures
b78af7a836928efd44317e82c8f2f9c86bb83ae915deef1b58dc6465dfa5436e
Getting image source signatures
Copying blob 8d3ac3489996 done  
Copying config c059bfaa84 done  
Writing manifest to image destination
Storing signatures
c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18
# podman images
REPOSITORY                             TAG         IMAGE ID      CREATED        SIZE
docker.io/library/nginx                latest      670dcc86b69d  4 months ago   146 MB
docker.io/i386/alpine                  edge        c9930b809cba  8 months ago   5.75 MB
registry.access.redhat.com/ubi8-micro  latest      a4b6df2ac2df  10 months ago  38.7 MB
docker.io/library/fedora               latest      b78af7a83692  12 months ago  159 MB
docker.io/library/alpine               latest      c059bfaa849c  12 months ago  5.87 MB

@auwsom
Copy link

auwsom commented Apr 24, 2023

I had to create the config file: /home/user/.config/containers/storage.conf

[storage]
driver = "overlay"
#runroot = "//containers/storage-runroot"
graphroot = "//containers/storage"
#rootless_storage_path = "//containers/storage"

The two commented lines were not needed to run rootless so far.
Move the container/* files to target and then sudo systemctl restart podman and podman info to check the config was changed.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Aug 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests