marcopalena / polito-os161-docker

A compact Docker image to compile, run and debug the teaching operating system OS/161.
MIT License
19 stars 6 forks source link

Empty home for selfbuilt image with volume #3

Closed whytox closed 2 years ago

whytox commented 2 years ago

Since I own an M1 mac I have compiled the image by myself.

The problem is that when running such images I don't get the os161 directory in /home/os161user if I use a custom volume.

I think the error is on the volume: the container contains all the files when running without a volume.

Here is the inspect command result for the volume:

[
    {
        "CreatedAt": "2022-03-18T09:45:20Z",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/os161-vol/_data",
        "Name": "os161-vol",
        "Options": {
            "device": "/Users/vito/Dropbox (Politecnico Di Torino Studenti)/Programmazione di Sistema/OS161/os161-volume",
            "o": "bind",
            "type": "none"
        },
        "Scope": "local"
    }
]

And here is the command I use to run the image with the volume:

docker run --volume os161-vol:/home/os161user --name os161 -it polito-os161 /bin/bash

Thank you.

marcopalena commented 2 years ago

@whytox I've experienced something similar when trying to re-create a volume with the same name after deleting its pre-existing content (but not the actual bound folder). You can try the following:

  1. Remove the container using the volume with docker rm os161
  2. Delete the volume with docker volume rm os161-vol
  3. Delete the folder you were binding to the volume rm -rf "/Users/vito/Dropbox (Politecnico Di Torino Studenti)/Programmazione di Sistema/OS161/os161-volume"
  4. Follow the steps to create a volume anew.
  5. Run the container mounting the new volume.

Hope this helps. If not, you can try to use a directory without spaces in its path as the folder that you bind to the volume. Spaces may be what's causing troubles.

whytox commented 2 years ago

Thank you, it worked!

os161user@37c0c72ddc3a:~$ uname -m
aarch64
os161user@37c0c72ddc3a:~$ ls -la
total 32
drwxr-xr-x 9 os161user os161user  288 Mar 18 12:18 .
drwxr-xr-x 1 root      root      4096 Mar 18 10:20 ..
-rw-r--r-- 1 os161user os161user 6148 Mar 18 12:17 .DS_Store
-rw-r--r-- 1 os161user os161user  220 Feb 25  2020 .bash_logout
-rw-r--r-- 1 os161user os161user 3771 Feb 25  2020 .bashrc
-rwxr-xr-x 1 os161user os161user   26 Mar 17 19:01 .gdbinit
-rw-r--r-- 1 os161user os161user  807 Feb 25  2020 .profile
drwxr-xr-x 6 os161user os161user  192 Mar 18 12:19 .vscode-server
drwxr-xr-x 7 os161user os161user  224 Mar 18 12:17 os161