{"id":853,"date":"2017-04-21T05:51:03","date_gmt":"2017-04-21T05:51:03","guid":{"rendered":"http:\/\/opm-project.org\/?page_id=853"},"modified":"2018-02-05T08:44:22","modified_gmt":"2018-02-05T08:44:22","slug":"running-flow-in-docker","status":"publish","type":"page","link":"https:\/\/opm-project.org\/?page_id=853","title":{"rendered":"Running Flow in Docker"},"content":{"rendered":"<p>This tutorial will show you how to run OPM Flow in a docker container. A large benefit of using a docker container is that you have an easy way to run the most recent version of Flow on Linux machines without precompiled binary packages. It is also very easy to remove from your system, should you not want to have it installed.<\/p>\n<p>It is possible to run this tutorial on modern Windows computers as well as on macOS. However, Docker for Windows has a set of requirements that have to be fulfilled, so not all computers will easily run Docker.<\/p>\n<p>A thorough discussion of containers is outside the scope of this tutorial, but a Docker container can be thought of as something similar to a virtual machine. The major difference is that a container is slightly less flexible, but much smaller in size, and with far less overhead than a virtual machine. So whilst running OPM Flow in a virtual machine will impose a performance penalty, doing so from a Docker container will be more or less as fast as running directly in your operating system.<\/p>\n<p><!--nextpage--><\/p>\n<h4>Setting up Docker and pulling the OPM release<\/h4>\n<p>To run a Docker container, we first need to install Docker. On modern Ubuntu machines, this can be done using the commands<\/p>\n<pre><code># Make sure apt-get is updated\r\nsudo apt-get update\r\n\r\n# Install docker\r\nsudo apt-get install -y docker.io\r\n<\/code><\/pre>\n<p>On other platforms, you can look at the <a href=\"https:\/\/docs.docker.com\/engine\/installation\/binaries\/\" target=\"_blank\">docker installation instructions<\/a> on how to install on your system. Docker is supported on Linux, macOS, and recent versions of Windows.<\/p>\n<p>Now that we have installed Docker, we can fetch the precompiled Docker image from the Docker hub with the following command:<\/p>\n<pre><code>sudo docker pull openporousmedia\/opmreleases\r\n<\/code><\/pre>\n<p>This will download the Docker image repository called\u00a0<em>opmreleases<\/em> from the\u00a0<em>openporousmedia<\/em> user to your local machine. Downloading will take some time depending on your connection speed, since a typical image size is a couple of hundred megabytes of data. Once this has completed, you should have a command window similar to the following.<\/p>\n<p><a href=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/docker_pull.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-871\" src=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/docker_pull.png\" alt=\"docker_pull\" width=\"772\" height=\"454\" \/><\/a><\/p>\n<p><!--nextpage--><\/p>\n<h4>Running a command in a Docker container<\/h4>\n<p>Docker enables you to run commands from within the container such as the following<\/p>\n<pre><code>sudo docker run openporousmedia\/opmreleases:latest &lt;COMMAND&gt;\r\n<\/code><\/pre>\n<p>this command (on one line) tells docker to run the <em>latest<\/em> container of the <em>opmreleases<\/em> repository of the <em>openporousmedia<\/em> user on Docker hub. This was the image we downloaded earlier in this tutorial. As an example, we can list the flow_ebos executable:<\/p>\n<pre><code># List the flow executable on the host\r\n# machine(typically does not exist)\r\nls \/usr\/bin\/flow\r\n\r\n# List the flow executable in the\r\n# Docker container\r\nsudo docker run openporousmedia\/opmreleases:latest ls \/usr\/bin\/flow<\/code><\/pre>\n<p>The output of these commands should be similar to the following (note: outdated image refers to flow_ebos rather than flow)<\/p>\n<p><a href=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/docker_run.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872\" src=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/docker_run.png\" alt=\"docker_run\" width=\"921\" height=\"421\" \/><\/a><\/p>\n<p><!--nextpage--><\/p>\n<h4>Downloading simulation data<\/h4>\n<p>We will now run a simulation case case available from the <a href=\"https:\/\/github.com\/OPM\/opm-data\/\" target=\"_blank\">opm-data<\/a> repository. The easiest way to get the data is to download a zip-file from <a href=\"https:\/\/github.com\/OPM\/opm-data\/archive\/master.zip\" target=\"_blank\">https:\/\/github.com\/OPM\/opm-data\/archive\/master.zip<\/a>. On Linux first create and enter a new directory in your home directory (in our case called docker_simulations), and then download the data and unzip:<\/p>\n<pre><code># Go to home directory\r\ncd ~\/\r\n\r\n# Create new directory\r\nmkdir docker_simulations\r\ncd docker_simulations\r\n\r\n# Download data - will take some time\r\nwget https:\/\/github.com\/OPM\/opm-data\/archive\/master.zip\r\n\r\n# Unzip data\r\nunzip master.zip\r\n\r\n# Show current path and list directory contents\r\npwd\r\nls\r\nls opm-data-master\r\n<\/code><\/pre>\n<p>You should now have a directory similar to the following<\/p>\n<p><a href=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/opm_data_unzip.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-875\" src=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/opm_data_unzip.png\" alt=\"opm_data_unzip\" width=\"821\" height=\"423\" \/><\/a><\/p>\n<p><!--nextpage--><\/p>\n<h4>Running the Norne simulation case<\/h4>\n<p>We are now ready to run the Norne benchmark. To access the data we just downloaded from within the Docker container, we must mount it when running docker. The image has been set up so that the directory &#8220;<em>\/shared_host&#8221;<\/em> in the Docker container can point to a directory on the host. This can be done in the following fashion:<\/p>\n<pre><code># List the Norne directory on the host\r\nls opm-data-master\/norne\r\n\r\n# Save path of current directory in environment variable\r\nHOST_DIR=$(pwd)\r\n\r\n# Mount the path in the docker container\r\nsudo docker run -v $HOST_DIR:\/shared_host openporousmedia\/opmreleases:latest ls \/shared_host\/opm-data-master\/norne<\/code><\/pre>\n<p>The result should be similar to the following:<\/p>\n<p><a href=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/docker_mount.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-870\" src=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/docker_mount.png\" alt=\"docker_mount\" width=\"824\" height=\"422\" \/><\/a><\/p>\n<p>Now we can run the Norne benchmark using the following docker command<\/p>\n<pre><code>sudo docker run -v $HOST_DIR:\/shared_host openporousmedia\/opmreleases:latest flow output_dir=\"\/shared_host\/output\" \/shared_host\/opm-data-master\/norne\/NORNE_ATW2013.DATA\r\n<\/code><\/pre>\n<p>You should now see the Norne case start running, as shown in the following (note: outdated image refers to flow_ebos rather than flow)<\/p>\n<p><a href=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/docker_run_norne_start.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-874\" src=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/docker_run_norne_start.png\" alt=\"docker_run_norne_start\" width=\"821\" height=\"423\" \/><\/a><\/p>\n<p>The Norne case this way takes some time to complete, around 15 minutes on a modern computer.<\/p>\n<p>Because we asked flow to save the simulation results under <em>\/shared_host\/output<\/em> in the container, this is now available directly in the <em>docker_simulations<\/em> directory on the host:<\/p>\n<pre><code># List directories of \"docker_simulations\"\r\nls\r\n\r\n# List output of running the Norne simulation\r\nls output\r\n<\/code><\/pre>\n<p><a href=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/docker_run_norne_end.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-873\" src=\"\/\/opm-project.org\/wp-content\/uploads\/2017\/04\/docker_run_norne_end.png\" alt=\"docker_run_norne_end\" width=\"824\" height=\"421\" \/><\/a><\/p>\n<p>Congratulations! You have now completed running a simulation with flow using a Docker container. We can now inspect the results using\u00a0<a href=\"\/\/opm-project.org\/?page_id=117\" target=\"_blank\">ResInsight<\/a> as described in the <a href=\"\/\/opm-project.org\/?page_id=780\" target=\"_blank\">Running Norne tutorial<\/a>\u00a0or another tool of your choice.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial will show you how to run OPM Flow in a docker container. A large benefit of using a docker container is that you have an easy way to run the most recent version of Flow on Linux machines without precompiled binary packages. It is also very easy to remove from your system, should &hellip; <a href=\"https:\/\/opm-project.org\/?page_id=853\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Running Flow in Docker<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"parent":43,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/opm-project.org\/index.php?rest_route=\/wp\/v2\/pages\/853"}],"collection":[{"href":"https:\/\/opm-project.org\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/opm-project.org\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/opm-project.org\/index.php?rest_route=\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/opm-project.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=853"}],"version-history":[{"count":14,"href":"https:\/\/opm-project.org\/index.php?rest_route=\/wp\/v2\/pages\/853\/revisions"}],"predecessor-version":[{"id":1110,"href":"https:\/\/opm-project.org\/index.php?rest_route=\/wp\/v2\/pages\/853\/revisions\/1110"}],"up":[{"embeddable":true,"href":"https:\/\/opm-project.org\/index.php?rest_route=\/wp\/v2\/pages\/43"}],"wp:attachment":[{"href":"https:\/\/opm-project.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}