docker commands in mac for beginner
- Install in mac by home brew
> brew install docker
#Install docker
> brew install boot2docker
#Install boot2docker for virtualed docker engine
If your brew have not cask
that is extended module
else skip this command.
> brew install caskroom/cask/brew-cask
#Install cask for installing virtual box
> brew cask install virtualbox
#Install virtualbox
- Create docker image
> boot2docker init
#For creating virtualed docker engine
- Start docker
> boot2docker up
#You have to use boot2docker command for starting docker
> export DOCKER_HOST=tcp://192.168.59.103:2375
#You have to register docker host by environment variable, just input command
#It makes docker-client accessible docker-daemon
> boot2docker ssh
#Access docker by ssh
- Commands in docker
> docker version
> docker images
#Check images like ls in terminal
> docker container ls
#Check containers
- Pull image in docker
> docker pull [OS name]:[version]
#Download image from docker.io repository
#Example is > docker pull centos:6.4
- Run image to container in docker
> docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
#Run container.
#Example is docker run -ti --privileged -p 8090:8080
-a , --attach : attach stdin, stdout, stderr (STDIN, STDOUT, STDERR)
--cidfile: output container id by file
-d, --detach: run back ground
-i, --interactive: open container standard input (show situation in container)
-t, --tty: use tty
--name: naming of container
--privileged: connect by privileged mode
-p: forward request to virturalbox port to container inner port
- Remove container/image in docker
> docker rm [container-id]
#Remove container
> docker rmi [image-id]
#Remove image
> docker restart [container-id]
#Restart container
> docker attach [container-id]
#Attach container
- Commit in docker
> docker commit [container_id] [OS name]:[tag]
#Commit in docker
#It saves current container by image
- Exit docker
> exit
#Exit docker
- Stop boot2docker
> boot2docker stop
#Stop boot2docker