Tutorial by Examples: contain

docker ps --filter name=myapp_1
docker run --restart=always -d <container> By default, Docker will not restart containers when the Docker daemon restarts, for example after a host system reboot. Docker provides a restart policy for your containers by supplying the --restart command line option. Supplying --restart=always ...
To keep a container running in the background, supply the -d command line option during container startup: docker run -d busybox top The option -d runs the container in detached mode. It is also equivalent to -d=true. A container in detached mode cannot be removed automatically when it stops, t...
A Docker volume is a file or directory which persists beyond the lifetime of the container. It is possible to mount a host file or directory into a container as a volume (bypassing the UnionFS). Add a volume with the -v command line option: docker run -d -v "/data" awesome/app bootstrap....
To find out the IP address of your container, use: docker inspect <container id> | grep IPAddress or use docker inspect docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${CID}
docker restart <container> [<container>...] Option --time : Seconds to wait for stop before killing the container (default 10) docker restart <container> --time 10
docker rm can be used to remove a specific containers like this: docker rm <container name or id> To remove all containers you can use this expression: docker rm $(docker ps -qa) By default docker will not delete a container that is running. Any container that is running will produce a...
docker exec -it <container id> /bin/bash It is common to log in an already running container to make some quick tests or see what the application is doing. Often it denotes bad container use practices due to logs and changed files should be placed in volumes. This example allows us log in the...
It is possible to mount a host directory to a specific path in your container using the -v or --volume command line option. The following example will mount /etc on the host to /mnt/etc in the container: (on linux) docker run -v "/etc:/mnt/etc" alpine cat /mnt/etc/passwd (on windows) do...
Usage: docker logs [OPTIONS] CONTAINER Fetch the logs of a container -f, --follow=false Follow log output --help=false Print usage --since= Show logs since timestamp -t, --timestamps=false Show timestamps --tail=all Number o...
To execute operations in a container, use the docker exec command. Sometimes this is called "entering the container" as all commands are executed inside the container. docker exec -it container_id bash or docker exec -it container_id /bin/sh And now you have a shell in your running...
To get all the information for a container you can run: docker inspect <container>
You can get an specific information from a container by running: docker inspect -f '<format>' <container> For instance, you can get the Network Settings by running: docker inspect -f '{{ .NetworkSettings }}' <container> You can also get just the IP address: docker inspect ...
To run a container interactively, pass in the -it options: $ docker run -it ubuntu:14.04 bash root@8ef2356d919a:/# echo hi hi root@8ef2356d919a:/# -i keeps STDIN open, while -t allocates a pseudo-TTY.
To create a collection of n copies of some object x, use the fill method. This example creates a List, but this can work with other collections for which fill makes sense: // List.fill(n)(x) scala > List.fill(3)("Hello World") res0: List[String] = List(Hello World, Hello World, Hello...
Letters 3.0 let letters = CharacterSet.letters let phrase = "Test case" let range = phrase.rangeOfCharacter(from: letters) // range will be nil if no letters is found if let test = range { print("letters found") } else { print("letters not found") }...
This query returns all cones with a chocolate scoop and a vanilla scoop. VANILLA, CHOCOLATE, MINT, STRAWBERRY = 1, 2, 3, 4 # constants for flavors choco_vanilla_cones = IceCream.objects.filter(scoops__contains=[CHOCOLATE, VANILLA]) Don't forget to import the IceCream model from your models.py ...
This query returns all cones with either a mint scoop or a vanilla scoop. minty_vanilla_cones = IceCream.objects.filter(scoops__contained_by=[MINT, VANILLA])
Inspecting system resource usage is an efficient way to narrow down a problem on a live running application. This example is an equivalent of the traditional ps command for containers. docker top 7786807d8084 To filter of format the output, add ps options on the command line: docker top 7786807...
'Attaching to a container' is the act of starting a terminal session within the context that the container (and any programs therein) is running. This is primarily used for debugging purposes, but may also be needed if specific data needs to be passed to programs running within the container. The a...

Page 2 of 8