Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Mount from host filesystem #68

Closed
Brandl opened this issue Sep 9, 2014 · 8 comments
Closed

Mount from host filesystem #68

Brandl opened this issue Sep 9, 2014 · 8 comments

Comments

@Brandl
Copy link
Contributor

Brandl commented Sep 9, 2014

Yes, I know this is against Dockerfile best practice, but it's really required in my usecase. For backup and portability reasons all Docker container share a specific folder with the host filesystem. The approach so far was to manually create data-only-container and share them with the actual container.

I am willing to implement this feature into octohost, if you agree to one of this implementations:

  1. "magic" Dockerfile comment using "-v"-argument -> # MOUNT_FROM_HOST /docker/cont1storage
  2. If # VOLUMES_FROM is specified and "currentgitreponame_data" doesn't exist, spin one up

Do you agree, that this feature would be useful?
Which implementation do you prefer?

@darron
Copy link
Member

darron commented Sep 10, 2014

I think the MOUNT_FROM_HOST would be best - that keeps it separate from the old VOLUMES_FROM implementation that I'm not super fond of anyways.

@Brandl
Copy link
Contributor Author

Brandl commented Sep 21, 2014

Thats strange, it works perfectly if I leave out the echo in the following code:

    MOUNT_FROM_HOST=$(grep -i "^# MOUNT_FROM_HOST" $DOCKERFILE)
    if [ -n "$MOUNT_FROM_HOST" ]
    then
      HOST_PATH=$(grep -i "^# MOUNT_FROM_HOST" $DOCKERFILE | awk '{ print $3 }')
      CONTAINER_PATH=$(grep -i "^# MOUNT_FROM_HOST" $DOCKERFILE | awk '{ print $4 }')
      if [ -n "$CONTAINER_PATH" ]
      then
        MOUNT_PATH="$HOST_PATH:$CONTAINER_PATH"
      else
        MOUNT_PATH="$HOST_PATH:$HOST_PATH"
      fi

      RUN_OPTIONS="$RUN_OPTIONS -v $MOUNT_PATH"
      echo "Mounting at $MOUNT_PATH"
    fi

Otherwise it throws a error "Image with the name Mounting not found"(or something like that).

Any ideas?

@darron
Copy link
Member

darron commented Sep 22, 2014

You shouldn't likely echo in there - it's building a bunch of command line flags for the docker run command.

@aussielunix
Copy link

I had implemented this a little while ago but only pushed it this morning.
I too learnt that you can not echo feedback.

👍 to having this merged in.

@Brandl
Copy link
Contributor Author

Brandl commented Sep 23, 2014

Kinda confusing, because there actually is an echo, inside the "linking container"-block, which I used as a snippet. Nonetheless, it works as expected and I have been using it in Production since a week, so it could be merged:
25e8976 [#69]

For the docs:

# MOUNT_FROM_HOST /etc/data

results in -v /etc/data:/etc/data, which mounts /etc/data to the container filesystem

# MOUNT_FROM_HOST /host/data/docker-data /docker/container/data

results in -v /host/data/docker-data:/docker/container/data, which mounts/host/data/docker-data from the host filesystem to /docker/container/data on the container

(Hint: be aware, that file owner and permissions have to match in order for the container to read/write on the mounted folder!)

@NigelThorne
Copy link
Contributor

This is exactly what I need to get shipyard working. Please can we get this into master? Is there anything I can do to help?

@darron
Copy link
Member

darron commented Sep 24, 2014

I will merge as soon as I can. Will try to merge tomorrow.

Traveling at the moment with really crappy hotel internet.

@NigelThorne
Copy link
Contributor

Thanks. I'm loving octohost.


"Man, I'm going to have so many chickens when this lot hatch!"

On Wed, Sep 24, 2014 at 12:21 PM, darron froese notifications@github.com
wrote:

I will merge as soon as I can. Will try to merge tomorrow.

Traveling at the moment with really crappy hotel internet.


Reply to this email directly or view it on GitHub
#68 (comment).

darron added a commit that referenced this issue Sep 24, 2014
Added an _magic_ option mount host folder to container (#68)
@darron darron closed this as completed Sep 24, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants