Skip to content

Instantly share code, notes, and snippets.

@ObjectIsAdvantag
Last active December 3, 2015 09:59
Show Gist options
  • Save ObjectIsAdvantag/e1cd4dc739fc644ee6f7 to your computer and use it in GitHub Desktop.
Save ObjectIsAdvantag/e1cd4dc739fc644ee6f7 to your computer and use it in GitHub Desktop.
# Create a machine
# - Wait for the machine to come up
# - Check virtual box
# - Display the machine ip
CMD> docker-machine create --driver virtualbox <MACHINE>
CMD> docker-machine ip <MACHINE>
CMD> docker-machine inspect <MACHINE>
# Set env to the newly created machine
# Activate machine in the Windows Command Shell, ie sets the docker env
CMD> FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd <MACHINE>') DO %i
# ex : FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO %i
# IN PROGRESS docker-machine ls --filter state=Running | grep Running | cut -f 1 -d " "
# To check the machine as been activated
# - note : There are warning if other machines are not running (check virtual box)
CMD> docker-machine ls
# Pull an node image into the machine
# - loads the various image layers
CMD> docker pull node:argon-slim
# To run an interactive shell, in a new container
# - The -i flag starts an interactive container.
# - The -t flag creates a pseudo-TTY that attaches stdin and stdout.
# Start by opening a second CMD terminal so that you can interact with docker,
# - and use bash in the container simultaneously (and without having to reload the env)
CMD> start cmd
CMD2> docker ps
CMD> docker run -i -t node:0.12.7 /bin/bash
root@CONTAINER_ID# // enter your commands...
root@CONTAINER_ID# // to detach the tty without exiting the shell, use the escape sequence Ctrl-p + Ctrl-q.
root@CONTAINER_ID# Ctrl-p + Ctrl-q. // exits the container
CMD> docker ps -a
CMD> docker attach <CONTAINER_ID>
root@CONTAINER_ID# // enter your commands...
# Remove all containers
CMD> docker ps -a | awk '{print $1}' | grep -v 'CONTAINER' | xargs --no-run-if-empty docker rm
# If you want to connect on the docker engine
# - no need to, only usefull to understand what's going on, on the engine
# - or if you need to install tools you'll reuse again and again may be
CMD > docker-machine ssh <MACHINE>
docker@machine:~$ // to list images
docker@machine:~$ sudo less /mnt/sda1/var/lib/docker/repositories-aufs
docker@machine:~$ // to list the details of an image
docker@machine:~$ ls /mnt/sda1/var/lib/docker/aufs
docker@machine:~$ // to see containers
docker@machine:~$ sudo ls /mnt/sda1/var/lib/docker
docker@machine:~$ // install bash in boot2docker
docker@machine:~$ tce-load -wi bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment