Last active
July 4, 2016 09:34
-
-
Save auycro/c295990371ef27e820ae4ceffca23061 to your computer and use it in GitHub Desktop.
something about vagrant and docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set Up Vagrant | |
-initialize vagrant | |
$ vagrant init | |
-you can find a box in https://atlas.hashicorp.com/boxes/search | |
$ vagrant box add {box_name} | |
-config vagrantfile | |
Vagrant.configure("2") do |config| | |
config.vm.box = "hashicorp/precise64" | |
end | |
-test vagrant | |
$ vagrant up | |
$ vagrant ssh | |
- create new package | |
$ vagrant package --output {blahblah}.box | |
- clear vagrant (template vagrant) | |
$ vagrant destroy | |
$ rm Vagrantfile | |
$ vagrant box remove {template vagrant box} | |
****You shoud destroy vm_box before remove any package_box | |
- Then add new box to vagrant box and go on | |
$ vagrant box add {blahblahbox} {blahblah}.box | |
$ vagrant init {blahblahbox} | |
$ vagrant up | |
Some command in Ubuntu | |
- Download vim | |
$ sudo apt-get install vim | |
- Clear apt-get Cache | |
$ sudo apt-get clean | |
- Change host name | |
1.edit 2 files "/etc/hostname","/etc/hosts" | |
2.restart | |
Set Up Docker in Vagrant | |
install docker | |
$ curl -L https://get.docker.com/ |sh | |
$ docker version | |
add docker provision in VagrantFile | |
- config.vm.provision "docker" | |
Basic docker | |
List All containner | |
$ docker ps -a | |
Remove containner | |
$ docker rm {name} | |
$ docker stop $(docker ps -a -q) | |
$ docker rm $(docker ps -a -q) | |
Run Docker | |
$ docker run {repopsitory} | |
Check Images | |
$ docker images | |
Delete Image | |
$ docker rmi {images_name} | |
Save container | |
$ docker save -o xxxx.tar {images_name} | |
$ docker export {containner_id} > xxx.tar | |
Load container | |
$ docker load | |
$ docker import | |
Connect to bash inside containner | |
$ docker exec -it {containner_id} bash | |
Build new docker file | |
create dockerfike | |
$ touch Dockerfile | |
edit Dockerfile | |
[ref](https://docs.docker.com/engine/reference/builder/) | |
$ docker build -t {image-name} {path_to_Dockerfile} | |
Getting Start with mongo & docker | |
$ docker pull mongo:latest | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment