-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 41b0ab7.
- Loading branch information
Showing
72 changed files
with
2,523 additions
and
2,678 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Docker | ||
|
||
## Assorted Tricks | ||
|
||
### clean all containers | ||
|
||
```sh | ||
$ docker ps -qa | xargs -I{} docker rm {} | ||
``` | ||
|
||
### clean all images | ||
|
||
```sh | ||
$ docker images | ag '^<none' | awk '{print $3}' | xargs -I{} docker rmi {} | ||
``` | ||
|
||
### commit a container as an image | ||
|
||
```sh | ||
$ docker commit <idcontainer> <ninrod/blah> | ||
``` | ||
|
||
### open a shell session to a running container | ||
|
||
* normal case: | ||
|
||
```sh | ||
docker exec -it <mycontainer> bash | ||
``` | ||
|
||
* if you want to run tmux inside the container | ||
|
||
```sh | ||
# clever hack to overcome docker-exec tty propblem | ||
# see: https://github.com/docker/docker/issues/8755 | ||
# in particular, see this comment: https://github.com/docker/docker/issues/8755#issuecomment-83403289 | ||
docker exec -it $CONTAINER_NAME script -qc "zsh" /dev/null | ||
``` | ||
|
||
### copy a file from the container to the host | ||
|
||
```sh | ||
$ docker cp <containerId>:/file/path/within/container /host/path/target | ||
``` | ||
|
||
### discover the ip of the docker host | ||
|
||
* more info [here](https://github.com/docker/docker/issues/23177#issuecomment-228096508) | ||
|
||
```sh | ||
$ docker inspect -f '{{.NetworkSettings.Gateway}}' $HOSTNAME | ||
``` | ||
|
||
### sync timezone with host | ||
|
||
* just mount /etc/localtime, e.g: | ||
```sh | ||
docker run \ | ||
-d -t \ | ||
-v /etc/localtime:/etc/localtime:ro \ | ||
yourdocker/image | ||
``` | ||
|
||
|
||
## docker ps | ||
|
||
### shrink docker ps horizontal output length | ||
|
||
* use the --format option | ||
|
||
```sh | ||
alias dp='docker ps --format="table {{.ID}}\t{{.Names}}\t{{.Image}}\t{{.Command}}\t{{.Status}}"' | ||
``` | ||
|
||
## docker inspect | ||
|
||
|
||
### discover what is the real path of a mountpoint from within a container | ||
|
||
* relevant [so question](http://stackoverflow.com/q/39151188/4921402) | ||
* relevant [github issue](https://github.com/docker/docker/issues/26021) | ||
|
||
```sh | ||
# issued from the container that mounted the host's docker socket and client | ||
# of course, the results need to be parsed | ||
$ docker inspect --format '{{json .Mounts }}' <container> | ||
``` | ||
## docker tag | ||
|
||
```sh | ||
docker tag $TAG_ID full.image/name:version | ||
``` | ||
|
||
## docker save | docker load | ||
|
||
```sh | ||
$ docker save mynewimage > /tmp/mynewimage.tar | ||
$ docker load < /tmp/mynewimage.tar | ||
``` | ||
|
||
## Links | ||
|
||
* [nginx html5mode angularjs sample config](https://gist.github.com/cjus/b46a243ba610661a7efb) |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Vagrant tricks | ||
|
||
* accessing host from guest | ||
```ruby | ||
# given this config, you should be able to access the host with the same ip address as the guest only changing the last octet to `1` | ||
config.vm.network "private_network", ip: "192.168.56.2" | ||
|
||
# so your host ip would be `192.168.56.1` in the above case | ||
``` | ||
|
||
* vagrant file with `private network` configuration | ||
```ruby | ||
MACHINE_NAME = "arch" | ||
|
||
Vagrant.configure("2") do |config| | ||
config.ssh.insert_key = false | ||
|
||
config.vm.box = MACHINE_NAME | ||
config.vm.box_url = MACHINE_NAME + ".box" | ||
config.vm.hostname = MACHINE_NAME | ||
|
||
config.vm.network "private_network", ip: "192.168.56.2" | ||
config.vm.provider :virtualbox do |vb, override| | ||
vb.name = MACHINE_NAME | ||
vb.customize ["modifyvm", :id, "--memory", "4096"] | ||
|
||
# intel card funciona no CentOS | ||
vb.customize ["modifyvm", :id, "--nictype2", "82540EM"] | ||
end | ||
|
||
config.vm.synced_folder "..", "/vagrant", :mount_options => ["dmode=777", "fmode=666"] | ||
|
||
config.vm.network :forwarded_port, guest: 2375, host: 2375 | ||
|
||
# copy RSA keys to the VM | ||
config.vm.provision "file", source: "#{Dir.home}/.ssh/id_rsa.pub", destination: "~/.ssh/id_rsa.pub" | ||
config.vm.provision "file", source: "#{Dir.home}/.ssh/id_rsa", destination: "~/.ssh/id_rsa" | ||
config.vm.provision "shell", inline: "chmod 400 /home/vagrant/.ssh/id_rsa" | ||
config.vm.provision "shell", inline: "chmod 600 /home/vagrant/.ssh/id_rsa.pub" | ||
end | ||
|
||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Arch Linux (running on vagrant) Tricks | ||
|
||
## fix network cards | ||
|
||
```sh | ||
# find ip address of the vagrant machine | ||
$ ip addr show | ||
|
||
# interface will be down. bring it up | ||
$ sudo ip link set [eth0] up | ||
``` | ||
|
||
## Pacman tricks | ||
|
||
```sh | ||
$ pacman -Ss $package | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Centos tricks | ||
|
||
## installing fonts | ||
|
||
* just place a font in ~/.fonts | ||
* issue `fc-cache ~/.fonts` | ||
* done. | ||
|
||
## yum tricks | ||
|
||
* installing X on CentOS: `yum -y groupinstall "X Window System"` | ||
* installing a local package: `sudo yum --nogpgcheck localinstall xclip-0.12-1.el6.rf.x86_64.rpm` | ||
* enabling an alternativo repo: `sudo yum --enablerepo=epel info ansible` |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.