Instantly share code, notes, and snippets.

Embed
What would you like to do?
commands for docker
# create a docker machine.
# docker machines host docker containers.
# this docker machine will have > 1 CPU and > 1024Mb Ram which are the defaults, we name the machine default
# notice we are using virtual box as the VM, virtualbox was already installed for me
docker-machine create --driver=virtualbox --virtualbox-cpu-count 2 --virtualbox-memory "2048" default
# verify the cpu and memory we set above with inspect
docker-machine inspect default
# look at the created docker machines, notice the state is in stopped/paused
docker-machine ls
# start or restart the machine
docker-machine start default
# ssh into the machine, not something you need to do
docker-machine ssh default
# tell the docker command how to interact with the machine later
eval "$(docker-machine env default)"
# look at the images, empty at this point
docker images
# visit docker hub and search for an image
https://hub.docker.com/
# download an image, can take a while, this one is 2.8 Gb
docker pull kevinfaro/tetra_spark
# run the image, this also takes a while for this image, i think because this one is copying hdfs files
docker run --cpuset-cpus=0,1 -it --rm kevinfaro/tetra_spark
# view the images that are running, grab the container id for later
docker ps
# look at processes running within a container
docker top bd4b8e4ccec1
# log into container, just use bash, ssh is kind of discouraged and is an extra layer not needed, notice the --it is interactive mode
docker exec -it bd4b8e4ccec1 bash
# shutdown the image, sometimes this command does not work for me and I need to do a hard "docker-machine restart/stop"
docker kill bd4b8e4ccec1
# shutdown the VM hosting the containers
docker-machine stop default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment