Cannot start any container if volumes are included. Docker toolbox

I am running Docker Toolbox v. 1.13.1a Docker Toolbox v. 1.13.1a on Windows 7 Pro Service pack 1 x64 OS. with Virtual Box Version 5.1.14 r112924

when I try to launch any docker image, for example. official postgres image from Docker Hub with volumes disabled, it works great!

But when I enable the volumes it fails .

I tried all the official docs

The VM has a shared folder as needed and has full access for it. Also a screenshot of the shared folder.

In the case of my postgresql example, it crashes with the following log

 The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.utf8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are disabled. fixing permissions on existing directory /var/lib/postgresql/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting dynamic shared memory implementation ... posix selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting dynamic shared memory implementation ... posix creating configuration files ... ok running bootstrap script ... LOG: could not link file "pg_xlog/xlogtemp.27" to "pg_xlog/000000010000000000000001": Operation not permitted FATAL: could not open file "pg_xlog/000000010000000000000001": No such file or directory child process exited with exit code 1 initdb: removing contents of data directory "/var/lib/postgresql/data" 

I know his problem with folder permissions . But the curious is stuck! Tone thank you in advance

+5
source share
2 answers

I worked on this problem all day and came to the conclusion that at present it is simply impossible to run postgresql inside the docker container, keeping your data constant in a separate volume.

I even tried to start the container without being bound to that and copy the data that was originally in / var / lib / postgresql to the folder of my operating system (Windows 10 Home), and then copy it to the folder associated with the container itself.

Alas, I got the following error:

 FATAL: data directory "/var/lib/postgresql/data/pgadmin" has wrong ownership HINT: The server must be started by the user that owns the data directory. 

In conclusion: There is something wrong with the ownership and the correct user who owns it, and in order to be able to fix it, you will need a unix command line on Windows that can run dockers (something is currently not possible using Bash on Ubuntu on Windows, which works using Ubuntu binary 16.04).

You may be able to run the necessary commands in the future (here, under Arbitrary --user Notes ), but these * nix commands and powershell (launched by Kitematic) cannot run them. Bash for Ubuntu for Windows can run them, but this shell has no connection to the docker / service daemon on windows ...

TL DR: Lost day of work: on Windows, this is not possible.

+2
source

I also tried to fix this problem.

At first, I thought it was a problem with symbolic linking (because the first error didn’t work, "failed to bind .. operation is not allowed)

To make sure that a symbolic link is enabled, you need to:

  • share folder in virtualbox
  • run virtualbox as an administrator (if your account is in the administrator group) Right-click virtualbox.exe and select "Run as administrator"
  • If your account is not an administrator, add the symlink privilege using secpol.msc > Local Policies - secpol.msc User Rights, add the user to Create Symbolic Links
  • enable a symbolic link for your shared folder in the virtual box:

VBoxManage setextradata VM_NAME VBoxInternal2 / SharedFoldersEnableSymlinksCreate / SHARED_FOLDER_NAME 1

Alternatively, you can also use the c:\User\username folder, which is public, and symlink is enabled by default on dockertools installation

Now I can create symbolic links in the shared folder from the docker container. But I still have the same error "failed to bind ... operation not allowed"

So, the reason should be somewhere else ... in the file permissions, as you said, but I don’t understand why?

0
source

Source: https://habr.com/ru/post/1266122/


All Articles