gimoh / docker-pureftpd

Pure-FTPD in a docker container
GNU General Public License v3.0
16 stars 8 forks source link

Question about creating user in container #2

Closed joenap closed 8 years ago

joenap commented 8 years ago

Hi,

I'm using your project as a base for an image in a testing pipeline. I want to bake the user creation process, using 'adduser-ftp', into the Dockerfile.

My file contents follow: `FROM gimoh/pureftpd

ENV PURE_USERS isolated+noanon+virt ENV PURE_VIRT_USER_HOME_PATTERN /srv/ftp/@USER@/./@USER@

WORKDIR /root COPY passwd.txt . RUN adduser-ftp ftpuser -m < passwd.txt`

When I do this, the /etc/pureftpd/passwd and /etc/pureftpd/passwd.pdb files aren't automatically created. This only happens when done through the Dockerfile.

However, if I exec into the container and run adduser-ftp ftpuser -m < passwd.txt manually, it creates the files.

I know this isn't an issue with docker-pureftpd project, but I'm curious if you can provide any insight on this issue. It would help us immensely.

Thanks, Joe

gimoh commented 8 years ago

Had a quick look, first problem is that the variables that define the location of password database aren't marked for export until dkr-init.sh runs (i.e. until runtime); this itself should be an easy fix (add appropriate "export" statements into pure_defaults.sh); I suspect another problem will be that the config directory is only created at runtime too. This was done so that the location of the config directory can be changed by passing an --env option to docker run.

Let me play about with it, I'll see what I can come up with ;-)

joenap commented 8 years ago

Gimoh, thanks for responding. I believe what you're saying is right, after looking into it deeper.

In the meantime, I have a working solution with vsftpd:

FROM vimagick/vsftpd
WORKDIR /root
COPY passwd.txt .
RUN mkdir -p /srv/ftp/ftpuser
RUN adduser ftpuser -h /srv/ftp/ftpuser < passwd.txt

This is used as a test fixture in a system test suite. Since I have this working, I'll probably stick with it. Although hopefully it can help motivate the design, in an attempt to keep this use-case simple.

Thanks again for popping in. I really appreciate it.

Cheers

gimoh commented 8 years ago

Nae problem ;-) Got it sorted anyway and added a note to README on how this can be done, just in case somebody finds this useful in the future.

I gotta admit, this would be simpler if CONFIGDIR wasn't configurable, but because it's often on a volume I wanted to leave this option in.

Thanks for trying to use that image and taking time to report this! you just helped make it better :-)