Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 50038cd

Browse files
authored
significantly simplified docker installation instructions (#58)
1 parent 238513d commit 50038cd

2 files changed

Lines changed: 44 additions & 83 deletions

File tree

README.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,22 @@ To install the latest PyPI release as a library (in user mode):
5252
Plugins
5353
=======
5454

55-
In order to simulate and compile quantum circuits or perform other complicated electronic structure calculations, one can install OpenFermion plugins. We currently support a circuit simulation plugin for `ProjectQ <https://projectq.ch>`__, which you can find at `OpenFermion-ProjectQ <http://github.com/quantumlib/OpenFermion-ProjectQ>`__. We also support electronic structure plugins for `Psi4 <http://psicode.org>`__, which you can find at `OpenFermion-Psi4 <http://github.com/quantumlib/OpenFermion-Psi4>`__ (recommended), and for `PySCF <https://github.com/sunqm/pyscf>`__, which you can find at `OpenFermion-PySCF <http://github.com/quantumlib/OpenFermion-PySCF>`__.
55+
In order to simulate and compile quantum circuits or perform other complicated
56+
electronic structure calculations, one can install OpenFermion plugins. We
57+
currently support a circuit simulation plugin for `ProjectQ
58+
<https://projectq.ch>`__, which you can find at `OpenFermion-ProjectQ
59+
<http://github.com/quantumlib/OpenFermion-ProjectQ>`__. We also support
60+
electronic structure plugins for `Psi4 <http://psicode.org>`__, which you can
61+
find at `OpenFermion-Psi4 <http://github.com/quantumlib/OpenFermion-Psi4>`__
62+
(recommended), and for `PySCF <https://github.com/sunqm/pyscf>`__, which you can
63+
find at `OpenFermion-PySCF <http://github.com/quantumlib/OpenFermion-PySCF>`__
64+
(less supported).
5665
For a particularly robust method of installing OpenFermion together with select
5766
plugins, we have provided a Docker image and usage instructions in the
5867
`docker folder <https://github.com/quantumlib/OpenFermion/tree/master/docker>`__
5968
(the Docker image provides a virtual environment configured with the OpenFermion
60-
libraries pre-installed).
69+
libraries pre-installed). The Docker installation can be run on any operating
70+
system (yes, even Windows).
6171

6272

6373
How to contribute

docker/README.md

Lines changed: 32 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Docker setup for OpenFermion and select plugins
22

3-
This Docker image will help users to easily install [OpenFermion](https://github.com/quantumlib/OpenFermion) and its available plugins for [ProjectQ](https://github.com/ProjectQ-Framework/ProjectQ), [Psi4](https://github.com/quantumlib/OpenFermion-Psi4), and [PySCF](https://github.com/quantumlib/OpenFermion-PySCF). Check out Docker's [website](https://www.docker.com/what-container) that describes what a container image is and why it can be so useful.
3+
This Docker image will help users to install [OpenFermion](https://github.com/quantumlib/OpenFermion) and its available plugins for [ProjectQ](https://github.com/ProjectQ-Framework/ProjectQ), [Psi4](https://github.com/quantumlib/OpenFermion-Psi4), and [PySCF](https://github.com/quantumlib/OpenFermion-PySCF).
4+
Check out Docker's [website](https://www.docker.com/what-container) that describes what a container image is and why it can be so useful.
5+
The Docker based installation is extremely robust and runs on any operating
6+
system and so is an ideal solution for anyone having difficulty installing
7+
OpenFermion (or any of its plugins) using the standard installation.
48

59

610
## What's included?
@@ -16,123 +20,70 @@ This Docker image will help users to easily install [OpenFermion](https://github
1620
- [PySCF](https://github.com/sunqm/pyscf)
1721

1822

19-
## Usage
20-
21-
To use this image, you first need to install [Docker](https://www.docker.com/).
22-
Then, to build the Docker image, move the
23-
[dockerfile](https://github.com/quantumlib/OpenFermion/blob/master/docker/dockerfile)
24-
to your working directory and execute:
25-
26-
```
27-
docker build -f dockerfile -t openfermion_docker .
28-
```
29-
30-
Finally, to run the image (assuming you're still inside your working directory), execute with `YOUR_WORK_DIR` as the path to your working directory:
31-
32-
```
33-
docker run -it -v $(pwd):YOUR_WORK_DIR -w YOUR_WORK_DIR openfermion_docker
34-
```
35-
36-
When you are done with the Docker image, you can use `docker stop
37-
YOUR_CONTAINER_ID` or `docker kill YOUR_CONTAINER_ID` to stop your container
38-
(you can get your container ID by entering the command `docker ps`). Finally,
39-
feel free to change your copy of the dockerfile to build a more customized
40-
image. For example, you may want to minimze the number of layers by combining the `RUN` statements to further reduce the image size.
41-
42-
43-
## Example
44-
45-
Suppose your working directory were called `openfermion_test`. Go to that
46-
directory (which would contain your scripts) and copy over the dockefile. Build the image. Your run command would then be:
47-
48-
```
49-
docker run -it -v $(pwd):/openfermion_test -w /openfermion_test openfermion_docker
50-
```
51-
52-
5323
## Setting up Docker for the first time
5424

55-
56-
When Docker is installed, open a command line terminal and check the list of
57-
running virtual machines by
25+
You first need to install [Docker](https://www.docker.com/).
26+
Once Docker is installed, open a command line terminal and check the list of
27+
running virtual machines with
5828

5929
```
60-
docker-machine ls
30+
docker-machine ls
6131
```
6232

6333
Assuming this is the firt time Docker has been run, the list should be empty.
6434
Create a virtual machine by running
6535

6636
```
67-
docker-machine create --driver virtualbox default
37+
docker-machine create --driver virtualbox default
6838
```
6939

7040
To be able to run this, one needs to install
71-
[virtualbox](https://www.virtualbox.org/wiki/Downloads).
41+
[VirtualBox](https://www.virtualbox.org/wiki/Downloads).
7242
Here, "default" is just the name of the virtual machine. You can replace it by
7343
any name that you prefer. To check that the virtual machine is indeed running,
7444
use `docker-machine ls` again.
75-
76-
When the Docker virtual machine is created, configure the shell by running
45+
After the Docker virtual machine is created, configure the shell by running
7746

7847
```
79-
docker-machine env default
48+
docker-machine env default
8049
```
8150

8251
where if you named the virtual machine differently from default you should also
8352
replace "default" with the customized name. The command above will return an OS
84-
dependent message containing the command to run for configuring the shell.
53+
dependent message containing the command to run for configuring the shell;
54+
follow those instructions.
8555

8656

8757
## Running OpenFermion with Docker
8858

89-
Now that Docker is set up, one could navigate to the folder containing the
59+
Now that Docker is set up, one can navigate to the folder containing the
9060
Dockerfile for building the OpenFermion image (docker/dockerfile) and run
9161

9262
```
93-
docker build -t openfermion_docker .
94-
```
95-
96-
where "openfermion_docker" is just an arbitrary name.
97-
It takes a few minutes to build the image. What the Dockerfile does is to
98-
start from a base image of Ubuntu and install OpenFermion, its plugins and the
99-
necessary applications needed for running these programs. To run the image, use
100-
101-
```
102-
docker run -it openfermion_docker
63+
docker build -t openfermion_docker .
10364
```
10465

105-
and the terminal enters a new environment which emulates a Ubuntu OS with
106-
OpenFermion and accessories installed, regardless of what the host OS is. This
107-
new environment is a running process called a Docker container. To check info
108-
on the container, one can open another terminal, configure it using
109-
`docker-machine env` as mentioned before, and run
66+
where "openfermion_docker" is just an arbitrary name for our docker container.
67+
What the Dockerfile does is to start from a base image of Ubuntu and install
68+
OpenFermion, its plugins and the necessary applications needed for running these
69+
programs. This is a fairly involved installation and will take some time
70+
(perhaps up to thiry minutes depending on the computer). Once installation has
71+
completed, run the image with
11072

11173
```
112-
docker ps
74+
docker run -it openfermion_docker
11375
```
11476

115-
which returns a list of running containers. For example it might look like:
116-
117-
```
118-
CONTAINER ID IMAGE COMMAND CREATED
119-
STATUS PORTS NAMES
120-
3cc87ed4205b 5a67a4d66d05 "/bin/bash" 29 hours ago
121-
Up 29 hours blissful_brown
122-
```
123-
124-
in which case we have a running container called blissful_brown that was
125-
started quite a while ago.
126-
127-
The freshly built image is ready to run any Python program that uses
77+
With this command the terminal enters a new environment which emulates a Ubuntu OS with
78+
OpenFermion and accessories installed. The freshly built image is ready to run any Python program that uses
12879
OpenFermion. To transfer files from somewhere on the disk to the Docker
12980
container, run in a separate terminal from the one running the container
13081

13182
```
132-
docker cp [path to file on disk] [container name]:[path in container]
83+
docker cp [path to file on disk] [container name]:[path in container]
13384
```
13485

135-
where container name can be gleaned according to the step above.
86+
where container name is "openfermion_docker" in this case.
13687

13788
An alternative way of loading files onto the Docker container is through
13889
remote repos such as Github or BitBucket. git is installed in the Docker image.
@@ -142,7 +93,7 @@ to open up multiple terminals to run the same Docker container.
14293
In that case, one could run in any terminal
14394

14495
```
145-
docker exec -it [container name] bash
96+
docker exec -it [container name] bash
14697
```
14798

14899
and "get into" the container.
@@ -153,7 +104,7 @@ To run Jupyter notebook in a browser with a Docker container running as a
153104
backend, first check the ip address of the virtual machine by running
154105

155106
```
156-
docker-machine ip default
107+
docker-machine ip default
157108
```
158109

159110
where "default" can be replaced by the name of whichever virtual machine whose
@@ -164,7 +115,7 @@ openfermion_docker, run the container with an additional -p flag:
164115

165116

166117
```
167-
docker run -it -p 8888:8888 openfermion_docker
118+
docker run -it -p 8888:8888 openfermion_docker
168119
```
169120

170121
Here the numbers 8888 simply specifies the port number through which the Docker
@@ -174,7 +125,7 @@ available, any other number in 8000-9000 will do.
174125
When the terminal enters the Docker container, run Jupyter notebook by
175126

176127
```
177-
jupyter-notebook --allow-root --no-browser --port 8888 --ip=0.0.0.0
128+
jupyter-notebook --allow-root --no-browser --port 8888 --ip=0.0.0.0
178129
```
179130

180131
where 8888 is the port number used previously for setting up the container.

0 commit comments

Comments
 (0)