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

Mount from host filesystem #68

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

Comments

Projects
None yet
4 participants
@Brandl
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

This comment has been minimized.

Show comment
Hide comment
@darron

darron Sep 10, 2014

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@Brandl

Brandl Sep 21, 2014

Contributor

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?

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@darron

darron Sep 22, 2014

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@aussielunix

aussielunix Sep 23, 2014

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.

aussielunix commented Sep 23, 2014

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

This comment has been minimized.

Show comment
Hide comment
@Brandl

Brandl Sep 23, 2014

Contributor

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!)

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@NigelThorne

NigelThorne Sep 24, 2014

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?

Contributor

NigelThorne commented Sep 24, 2014

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

This comment has been minimized.

Show comment
Hide comment
@darron

darron Sep 24, 2014

Member

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

Traveling at the moment with really crappy hotel internet.

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

This comment has been minimized.

Show comment
Hide comment
@NigelThorne

NigelThorne Sep 24, 2014

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).

Contributor

NigelThorne commented Sep 24, 2014

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

Merge pull request #69 from Brandl/mount-from-option
Added an _magic_ option mount host folder to container (#68)

@darron darron closed this Sep 24, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment