Search code examples
dockercontainersibm-cloud

Equivalent of local host files for running Bluemix containers


When running a docker container locally you can run it with a command like this:

docker run --name some-nginx -v /some/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx

This will use the file /some/nginx.conf in place of /etc/nginx/nginx.conf within your running docker container. This is very handy if you don't want to permanently enshrine your configuration files inside of an image.

However, when running Bluemix containers there is no local filesystem as everything is on a remote host. Is there an equivalent option available?

Without this it seems like the best options are either to build a dedicated image with your configuration or to put the entire configuration as a user provided service. Is this a correct assumption?


Solution

  • You can create a volume and add the configuration files you want to persist on it. The volume is not deleted when a container instance is removed and it can be used by multiple containers.

    To create a volume you can use the following command:

    $ cf ic volume create my_volume
    

    Then you can create a new container and mount the volume to a path in the container, for example:

    $ cf ic run -v my_volume:/path/to/mount --name my_container my_image
    

    You can find more details in the following documentation link:

    https://console.ng.bluemix.net/docs/containers/container_creating_ov.html#container_volumes_ov