Docker¶
This page contains information about Docker that is useful for installation, administration, and development.
Installing Docker¶
Docker Engine and Docker Compose
On OS X:
Install Docker for Mac.
On Ubuntu:
If you have difficulties with the
aptinstall, try thepipinstall.The docker group is automatically created. Adding your user to the docker group avoids having to use sudo to run docker commands. Note that depending on how users/groups are set up, you may need to manually need to add your user to the group in
/etc/group.
While Docker is available on other platforms (e.g., Windows, Red Hat Enterprise Linux), the SFM team does not have any experience running SFM on those platforms.
Helpful commands¶
docker-compose up -dBring up all of the containers specified in the docker-compose.yml file. If a container has not yet been pulled, it will be pulled. If a container has not yet been built it will be built. If a container has been stopped (“killed”) it will be re-started. Otherwise, a new container will be created and started (“run”).
docker-compose pullPull the latest images for all of the containers specified in the docker-compose.yml file with the image field.
docker-compose buildBuild images for all of the containers specified in the docker-compose.yml file with the build field. Add--no-cacheto re-build the entire image (which you might want to do if the image isn’t building as expected).
docker psList running containers. Add
-ato also list stopped containers.docker-compose killStop all containers.
docker kill <container name>Stop a single container.
docker-compose rm -v --forceDelete the containers and volumes.
docker rm -v <container name>Delete a single container and volume.
docker rm $(docker ps -a -q) -vDelete all containers.
docker-compose logsList the logs from all containers. Add
-fto follow the logs.docker logs <container name>List the log from a single container. Add
-fto follow the logs.docker-compose -f <docker-compose.yml filename> <command>Use a different docker-compose.yml file instead of the default.
docker exec -it <container name> /bin/bashShell into a container.
docker rmi <image name>Delete an image.
docker rmi $(docker images -q)Delete all images
docker-compose scale <service name>=<number of instances>Create multiple instances of a service.
Scaling up with Docker¶
Most harvesters and exporters handle one request at a time; requests for exports and harvests queue up waiting to be handled. If requests are taking too long to be processed you can scale up (i.e., create additional instances of) the appropriate harvester or exporter.
To create multiple instances of a service, use docker-compose scale.
The harvester most likely to need scaling is the Twitter REST harvester since some harvests (e.g., broad Twitter searches) may take a long time. To scale up the Twitter REST harvester to 3 instances use:
docker-compose scale twitterrestharvester=3
To spread containers across multiple containers, use Docker Swarm.
Using compose in production provides some additional guidance.
Stopping Docker from automatically starting¶
Docker automatically starts when the server starts. To control this, see Configure Docker to start on boot.