Journal: Software Development

Email: mail@appsoftware.com

Software development notes and articles

A journal for sharing all things software development related


Common Commands

Mon, 10 Jun 2019 16:34 UTC

CPU, Memory useage

$ docker stats

Get container logs

$ docker logs -f <CONTAINER>

Stop all running containers:

$ docker stop $(docker ps -aq)

Build in current directory

$ docker build -t \<image name\> .

Run image as container

$ docker run -d -p 8080:80 \<image name\>

Remove all containers / images: (Needs checking)

$ docker rm -vf $(docker ps -a -q)

Prune any containers / images that are lying around:

This will remove, stopped containers, networks not used by any container, volumes not used by any container, images not associated with any container, build cache.

$ docker system prune -a --volumes

Copy file out from container to working directory (.):

$ docker cp \<container id\>:app/2019-06-10.log.json .

Note that the above needed the 'app' portion of the path

Exec run commands on container (e.g. to list files)

$ docker exec -t -i  \<container id or name\> /bin/bash

Can then ls, but to read log file need to enter path and file name as a string.

$ cat "logs\2019-06-13.log.json"

Possible alternative

$ docker run --rm -it --entrypoint=/bin/bash app-software-journal-web-ui

https://stackoverflow.com/questions/20813486/exploring-docker-containers-file-system

2lyhw9h3gs331.jpg

The information on this site is provided “AS IS” and without warranties of any kind either express or implied. To the fullest extent permissible pursuant to applicable laws, the author disclaims all warranties, express or implied, including, but not limited to, implied warranties of merchantability, non-infringement and suitability for a particular purpose.