Difference between revisions of "Dockers"
From My Wiki
(Created page with " == Show all containers == docker ps -a == Create mysql Docker with mapping to host == docker run --name mysqldb -v /data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD="q...") |
|||
| Line 15: | Line 15: | ||
docker exec -it mysqldb "bash" | docker exec -it mysqldb "bash" | ||
| + | |||
| + | == exit container without closing == | ||
| + | |||
| + | crtl+shift+D | ||
| + | |||
| + | |||
| + | == container specific logs (to view the output of commands running in container) == | ||
| + | docker logs mysqldb | ||
== Create volume and map container to it == | == Create volume and map container to it == | ||
| Line 20: | Line 28: | ||
docker volume create vol1 | docker volume create vol1 | ||
docker run --name mysqldb_map -v vol1:/var/lib/mysql -e MYSQL_ROOT_PASSWORD="qweQWE123" -p 3306:3306 -it mysql/mysql-server:5.7 | docker run --name mysqldb_map -v vol1:/var/lib/mysql -e MYSQL_ROOT_PASSWORD="qweQWE123" -p 3306:3306 -it mysql/mysql-server:5.7 | ||
| + | |||
| + | |||
| + | == view details for specific docker == | ||
| + | |||
| + | docker inspect mysqldb_map | ||
| + | |||
| + | |||
| + | == rename a container == | ||
| + | |||
| + | docker rename CONTAINER NEW_NAME | ||
| + | |||
| + | |||
| + | == copy files into docker container == | ||
| + | |||
| + | docker cp 1.txt mycontainer:/1.txt | ||
| + | |||
| + | |||
| + | |||
| + | == run docker to map port 9000 to forward 3306 == | ||
| + | |||
| + | docker run -d -p 3306:9000 dockercloud/mysql | ||
| + | |||
| + | |||
| + | == Allow outbound forwarding for the container to the world == | ||
| + | |||
| + | on the host server run the following command: | ||
| + | sysctl net.ipv4.conf.all.forwarding=1 | ||
| + | iptables -P FORWARD ACCEPT | ||
Latest revision as of 14:16, 11 February 2019
Contents
- 1 Show all containers
- 2 Create mysql Docker with mapping to host
- 3 SSH to a container
- 4 exit container without closing
- 5 container specific logs (to view the output of commands running in container)
- 6 Create volume and map container to it
- 7 view details for specific docker
- 8 rename a container
- 9 copy files into docker container
- 10 run docker to map port 9000 to forward 3306
- 11 Allow outbound forwarding for the container to the world
Show all containers
docker ps -a
Create mysql Docker with mapping to host
docker run --name mysqldb -v /data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD="qweQWE123" -p 3306:3306 -it mysql/mysql-server:5.7
SSH to a container
docker exec -it mysqldb "bash"
exit container without closing
crtl+shift+D
container specific logs (to view the output of commands running in container)
docker logs mysqldb
Create volume and map container to it
docker volume create vol1 docker run --name mysqldb_map -v vol1:/var/lib/mysql -e MYSQL_ROOT_PASSWORD="qweQWE123" -p 3306:3306 -it mysql/mysql-server:5.7
view details for specific docker
docker inspect mysqldb_map
rename a container
docker rename CONTAINER NEW_NAME
copy files into docker container
docker cp 1.txt mycontainer:/1.txt
run docker to map port 9000 to forward 3306
docker run -d -p 3306:9000 dockercloud/mysql
Allow outbound forwarding for the container to the world
on the host server run the following command:
sysctl net.ipv4.conf.all.forwarding=1 iptables -P FORWARD ACCEPT