Skip to content

Commit

Permalink
many changes
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsiryk committed Apr 26, 2017
1 parent bb0884f commit 12a3e26
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 75 deletions.
112 changes: 60 additions & 52 deletions Docker/docker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
Docker
======

Clear container logs::

> $(docker inspect --format='{{.LogPath}}' <CONTAINER>)


To use node_modules locally, but ignore it in the docker container using the following syntax in the ``docker-compose.yml``. So everything in ``./angularApp`` is mapped to ``/opt/app`` and then I create another mount volume ``/opt/app/node_modules/`` which is now empty directory - even if in my local machine ``./angularApp/node_modules`` is not empty::
Expand All @@ -17,86 +19,92 @@ File ``.dockerignore``::
Dockerfile
docker-compose.yml



Exit without stopped::

Ctrl+p, Ctrl+q


The TERM environment variable is unset!::

export TERM=xterm


Ctrl+p, Ctrl+q # exit without stopped
::

docker ps # show running containers
-a # show all containers
-l # show last started container
docker ps # show running containers
-a # show all containers
-l # show last started container


docker search <image> # search images
docker search <image> # search images

docker pull <image>:<tag> # pull to local copy
docker pull <image>:<tag> # pull to local copy

docker run -t -i <image>:<tag> [comand]
<image>
-ti <image> # run end get TTY
-ti <image> [command] # run command
-d <image> [command] # run on background
-P ... # open all required ports
-p 80:5000 -p 85:5005 ... # 80 -> 5000
--name <some_name> # add name for container
--env MYVAR2=foo # add env variable
--env-file ./env.list # add env file
-v /etc/localtime:/etc/localtime:ro # mount volume or file
docker run -t -i <image>:<tag> [comand]
<image>
-ti <image> # run end get TTY
-ti <image> [command] # run command
-d <image> [command] # run on background
-P ... # open all required ports
-p 80:5000 -p 85:5005 ... # 80 -> 5000
--name <some_name> # add name for container
--env MYVAR2=foo # add env variable
--env-file ./env.list # add env file
-v /etc/localtime:/etc/localtime:ro # mount volume or file

--log-driver=syslog
--log-opt syslog-address=udp://<address>:514
--log-opt tag="some_tag"
--log-driver=syslog
--log-opt syslog-address=udp://<address>:514
--log-opt tag="some_tag"


docker images # show local images
-q # show only IDs
-f dangling=true # show trash images
docker images # show local images
-q # show only IDs
-f dangling=true # show trash images

docker rmi $(docker images -f dangling=true -q) # remove trash images
docker rmi $(docker images -f dangling=true -q) # remove trash images


docker port <name> # show opens ports
[port] # show port
docker port <name> # show opens ports
[port] # show port

docker logs <name> # Shows us the standard output of a container.
-f <name> # tail -f
docker logs <name> # Shows us the standard output of a container.
-f <name> # tail -f

docker stop <name> # stop running container. return name of stopped
docker stop <name> # stop running container. return name of stopped

docker start <name> # start stopping container. return name of started
-i <name> # and in
docker start <name> # start stopping container. return name of started
-i <name> # and in

docker atach <name> # atach to running container
docker atach <name> # atach to running container

docker rm <name> <name> ... # remove container if stopped
-f <name> <name> ... # remove container!
docker rm <name> <name> ... # remove container if stopped
-f <name> <name> ... # remove container!

docker rmi training/sinatra # remove images
docker rmi training/sinatra # remove images

docker cp <container>:<src_path_in_container> <dest_local_path> # cp files and directories. Example: backup data
docker cp <container>:<src_path_in_container> <dest_local_path> # cp files and directories. Example: backup data


docker top <name> # top for container
docker top <name> # top for container

docker inspect <name> # return json information
-f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <name>
docker commit -m "message" -a "John Smith" 0b2616b0e5a8 ouruser/sinatra:v2 # save current state of image
docker inspect <name> # return json information
-f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <name>
docker commit -m "message" -a "John Smith" 0b2616b0e5a8 ouruser/sinatra:v2 # save current state of image

docker tag 5db5f8471261 ouruser/sinatra:devel # add new tag
docker tag 5db5f8471261 ouruser/sinatra:devel # add new tag


# Images that use the v2 or later format have a content-addressable identifier called a digest.
# As long as the input used to generate the image is unchanged, the digest value is predictable.
# To list image digest values, use the --digests flag:
docker images --digests | head
docker pull ouruser/sinatra@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
Images that use the v2 or later format have a content-addressable identifier called a digest.
As long as the input used to generate the image is unchanged, the digest value is predictable.
To list image digest values, use the --digests flag::

docker push ouruser/sinatra
docker images --digests | head
docker pull ouruser/sinatra@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf

docker push ouruser/sinatra

# The TERM environment variable is unset!
export TERM=xterm


Docker monitoring
Expand All @@ -122,4 +130,4 @@ Run via docker::



7 changes: 7 additions & 0 deletions Docker/docker_compose.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ Bash completion (https://docs.docker.com/compose/completion/)::
--rmi all # + del all service images


Logging::

logging:
driver: "json-file"
options:
max-size: "100M"
max-file: "5"

::

Expand Down
12 changes: 12 additions & 0 deletions MacOS/mac_os.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
Mac OS
======

Set/get Computer/Host/LocalHost names. The settings are stored in ``/Library/Preferences/SystemConfiguration/preferences.plist``.::

# set
sudo scutil --set ComputerName "newname"
sudo scutil --set LocalHostName "newname"
sudo scutil --set HostName "newname"

# get
scutil --get ComputerName
scutil --get LocalHostName
scutil --get HostName


Allow only ssh key authentication ``/etc/ssh/sshd_config``::

Expand Down
46 changes: 27 additions & 19 deletions history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@
history
=======

~/.bash_history
History path ``~/.bash_history``.

Show history of commands::

history
20 # show last 20 commands
-c # clean history (don't forgot clear .bash_history file)
-d <num> # clear command

set +o history # off save history
set -o history # on save history

echo $HISTSIZE # show history size

<space>command # don't save history of this command


Exec command from history::

!<num> # show and exec specific command
!! # show and exec last command


Add time to history::

echo "export HISTTIMEFORMAT="%d.%m.%Y-%H:%M:%S \"" >> ~/.bashrc
source .bashrc

history
20 # show last 20 commands
-c # clean history (don't forgot clear .bash_history file)
-d <num> # clear command

!<num> # show and exec command
!! # show and exec last command

# Add time to history
echo "export HISTTIMEFORMAT="%d.%m.%Y-%H:%M:%S \"" >> ~/.bashrc
source .bashrc

set +o history # off save history
set -o history # on save history

echo $HISTSIZE # show history size

<space>command # don't save history of this command
6 changes: 5 additions & 1 deletion rsync.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@ rsync

Send big file on server::

rsync -v --progress --inplace <src> <user>@<ip>:</path/to/dest>
rsync -v -r --progress --inplace <src> <user>@<ip>:</path/to/dest>
-r # recursive
-v # verbosity
--progress # show progress during transfer


24 changes: 21 additions & 3 deletions vmware.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ VMWare command line

::

# start vm in background
vmrun start <path_to_vmx> nogui
# show running VM's
vmrun list

vmrun clone <path_to_vmx> <path_to_dest_vmx> full|linked [-snapshot=Snapshot Name] [-cloneName=Name]
# start VM in background
# If "Error: The file is already in use vmrun" delete *.lck dir (may be happen if vm was moved)
vmrun start <path_to_vmx> [gui|nogui]

# stop VM
stop <path_to_vmx> [hard|soft]

# clonning VM
vmrun clone <path_to_vmx> <path_to_dest_vmx> full|linked [-snapshot=from_snapshot_name] [-cloneName=Name]

# open GUI net configuration
vmware-netcfg
Expand All @@ -39,4 +47,14 @@ VMWare command line
# reload network (apply network config changes)
vmware-networks --stop && vmware-networks --start

# create cnapshot
vmrun snapshot <path_to.vmx> <snapshot_name>

# show snapshots
vmrun listSnapshots <path_to.vmx> [showTree]

# set VM state to a snapshot
vmrun revertToSnapshot <path_to.vmx> <snapshot_name>



0 comments on commit 12a3e26

Please sign in to comment.