Docker

Container Native (CN) - Docker

RELATED: SETUP > Dev Environment > Container - Docker | EXAMPLES > Cloud Solutions#Docker |

circle-info

Awesome References

Explore further

Useful Commands

Container

# start container
$ docker run [image_name][:image_version]
$ docker stop <container_name>
# restart container
$ docker start <container_name> 
chevron-rightStart container and enter the running containerhashtag
$ docker run -it <imageName> /bin/bash
root@47383646>:/# pwd
chevron-rightEnter already running containerhashtag
chevron-rightInspecting running containerhashtag
chevron-rightdocker run environment varshashtag
chevron-rightRemove all stop containershashtag

Image

chevron-rightTransfer image between host without using docker image repositoryhashtag

Ideally, the docker image is shared using the docker repository. However, if docker repository is not readily available, use the following docker save and docker load to transfer the image between host. To rebuild using the provided scripts is also an option, but some build could take a long time.

chevron-rightEnable --squash featurehashtag

Examples

chevron-rightCreate image - basic; basic website hosted by nginxhashtag
chevron-rightDocker compose; website - API - ElasticSearchhashtag
chevron-rightDocker compose; elasticsearch and python flask apphashtag
  • build -

  • environment - passing environment variables into the container

  • image - image name; can be replaced with build to build the image on the fly (build: .)

  • volumes - TBD

Docker Images - ready to use

Docker Networking

  • Docker Networking types:

    • bridge - the default network driver; used by in standalone container applications to communicate

    • host - used in docker swarm only; standalone container connects to the host network directly

    • overlay - used in docker swarm to connect multiple docker daemon

    • macvlan - used with legacy application, where a MAC address can be assigned to a container to have it appear as if it were a physical device on the network

    • none - completely disables network that is useful if a custom network driver is used

  • Docker container network topology is typically: 172.17.0.0/16. The docker bridge (docker0) connects to the docker network (172.17.0.1), the virtual Ethernet interfaces (i.e., veth0, veth1, etc.), as well as to the physical network (e.g., 192.168.1.10). All the containers (i.e., 172.17.0.2, 172.17.0.3, etc.) are connected to the docker network, and the virtual Ethernet interfaces (i.e., veth0, veth1, etc.) as well so that they can plug into the network switch. The docker bridge uses NAT to route the containers' traffic into the physical network.

  • Use nmap to inspect the network (docker run nmap)

  • Use ifconfig to show docker0, vethxxx

Last updated