-
-
Notifications
You must be signed in to change notification settings - Fork 165
Docker newbie1 instructions getting familiar with docker
-- by Mike Gage (and others)
The docker files for webwork were constructed by Pan Luo (@xcompass) at UBC. Thanks Pan!!
This explanation is by and for newbies and may well be simplified, clarified, corrected in later editions. (Jan 6, 2018, July 21, 2018)
The purpose of using docker is to allow nearly everyone who has worked with webwork using the command line to download and test new patches or pull requests to WeBWorK. The initial setup takes a bit more than an hour. After that you can pull a new experimental version of WeBWorK in five minutes for review without interfering with any of the existing work on the computer. Faster testing will allow us to proceed more quickly with new WeBWorK features.
The ways of setting up Docker are evolving. What follows is a relatively simple (if slightly time consuming way) of installing WeBWorK inside docker. We are experimenting with installing webwork2, pg, the mysql database and OPL separately as docker components and then connecting them. This will make it easier to modify and save files in each of these components and to rebuild without having to rebuild everything. (Rebuilding the library database in particular takes some time.) Those with some experience using Docker and webwork may want to look at https://github.com/openwebwork/webwork2/wiki/Docker---things-to-get-used-to-(and-avoid-surprises) and review and contribute to experiments described in the develop branch and on the forum
I have run docker on the MacOS high sierra and am now running it on Mojave. You need at least El Capitan MacOS in order to run Docker.
Docker CE has been successfully installed on Linux machines.
Docker CE is available for Windows machines as well, but getting WeBWorK running under Docker CE for Windows is a bit more complicated than doing so on MacOS X or Linux.
- Docker CE for Windows depends on Hyper-V, so only works on Windows Professional, Education, or Enterprise, but not on Windows Home.
- There is an older Docker Toolbox for Windows which works differently, and which may work on on machines whose version of Windows does not support Docker CE for Windows.
- When Hyper-V is activated during the installation of Docker, it disables VirtualBox and other VM hypervisiors. (They cannot operate in parallel.)
- In order to run VirtualBox again you have to disable Hyper-V. To do so: uncheck Hyper-V in Control Panel -> Programs -> Programs and Features -> Turn Windows features on or off. Then reboot.
- Getting WeBWorK to work in Docker for Windows also requires:
- getting symbolic links to work properly in Windows (possible on recent versions of Windows when Developer Mode is enabled)
- and sharing the Windows drive on which you have your
webwork2
folder.
- See:
Please report on your experiences. This wiki is versioned so don't worry about making mistakes when editing this document -- we can always restore an older version.
All commands are issued from the command line so you will need a terminal window. You will need some experience typing unix commands in order to follow these instructions.
Install Docker on your computer. (There are versions for Mac, Windows and Linux)
Docker download home Get the community edition. (CE)
The setup of docker on the Mac is standard and quick, see the Mac Instructions. For Windows see the Windows Instructions and https://servingmath.org/wp/2018/08/installing-webwork-on-docker-on-windows/
For Ubuntu 20.04 (LTS) follow the Ubuntu Instructions
Additionally install docker-compose
via
$ sudo apt install docker-compose
Test that it is installed by opening up a terminal and entering
$ docker --version
Docker version 18.06.0-ce, build 0ffa825
$ docker-compose --version
docker-compose version 1.22.0, build f46880f
$ docker-machine --version
docker-machine version 0.15.0, build b48dc28d
mkdir webwork_docker # (create a directory anywhere on your disk)
cd webwork_docker # all your work will be in this directory
docker run -d -p 80:80 --name webserver nginx # start a local webserver
after a few minutes an image of the nginx image will have been pulled from the cloud and a container running the webserver will have been created from the image.
In a web browser type http://localhost/
and return (see the Mac Instructions, Windows Instructions, pages above for expected response). Something along the lines of "welcome to nginx".
docker ps # see what containers are running, the first column is container ID
gage-imac-461:webwork_docker mgage$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
017118b37fef nginx "nginx -g 'daemon of�" 2 minutes ago Up 2 minutes 0.0.0.0:80->80/tcp webserver
docker logs CONTAINER_ID # print log/stdout of the container with CONTAINER_ID
gage-imac-461:webwork_docker mgage$ docker stop webserver
webserver
docker stop webserver # stop the server
docker ps # no container is running (they are all stopped and therefore "hidden").
docker ps -a # includes all of the containers including ones that are stopped.
gage-imac-461:webwork_docker mgage$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
017118b37fef nginx "nginx -g 'daemon of�" 5 minutes ago Exited (0) About a minute ago
webserver
docker start webserver # restart the server
docker rm -f webserver # remove the webserver (the -f stands for "force" )
# the image which you downloaded from the cloud and from which the container was created is still on your machine
docker images
gage-imac-461:webwork_docker mgage$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 7042885a156a 44 hours ago 109MB
docker rmi nginx # will remove the image completely
At this point you can read/skim the rest of the Mac Instructions, Windows Instructions, etc pages at your leisure. There are no changes that need to be made, but skimming to see what is available on this page can be helpful.
There is a second getting started page that is useful to read in order to get oriented. For example it explains the difference between a container and an image. You might also like to skim https://github.com/openwebwork/webwork2/wiki/Docker---things-to-get-used-to-(and-avoid-surprises)
Next step: actually set up a webwork installation using docker: https://github.com/openwebwork/webwork2/wiki/docker-newbie1.5-instructions----first-build-of-webwork