Yes, you can - but all of this information is also available on the outside and whenever you update the container, the additional tools will be removed again and you have to reinstall them then.
It is not good practice to install tools inside the docker image once it’s running, you could modify the docker file to create a new customized container image which also includes these tools.
Another alternative would be to map a statically compiled version of busybox f.ex. into the container. This would then allow you to run some common debugging commands directly from within the container:
# docker exec -u root -ti 98505b225dd4 /bin/bash
root@98505b225dd4:/mattermost# busybox netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 98505b225dd4:58696 mm-770-postgres-1.mm-770_default:5432 ESTABLISHED
tcp 0 0 98505b225dd4:36328 mm-770-postgres-1.mm-770_default:5432 TIME_WAIT
tcp 0 0 98505b225dd4:58712 mm-770-postgres-1.mm-770_default:5432 ESTABLISHED
tcp 0 0 98505b225dd4:34114 server-18-66-97-125.fra56.r.cloudfront.net:443 ESTABLISHED
tcp 0 0 98505b225dd4:58680 mm-770-postgres-1.mm-770_default:5432 ESTABLISHED
tcp 0 0 98505b225dd4:40220 server-18-66-112-60.fra56.r.cloudfront.net:443 ESTABLISHED
tcp 0 0 98505b225dd4:58738 mm-770-postgres-1.mm-770_default:5432 ESTABLISHED
tcp 0 0 98505b225dd4:58692 mm-770-postgres-1.mm-770_default:5432 ESTABLISHED
tcp 0 0 98505b225dd4:33942 server-13-32-121-69.fra60.r.cloudfront.net:443 ESTABLISHED
tcp 0 0 98505b225dd4:36336 mm-770-postgres-1.mm-770_default:5432 TIME_WAIT
tcp 0 0 localhost:35868 localhost:8065 TIME_WAIT
tcp 0 0 98505b225dd4:58704 mm-770-postgres-1.mm-770_default:5432 ESTABLISHED
tcp 0 0 98505b225dd4:41040 server-18-66-97-74.fra56.r.cloudfront.net:443 ESTABLISHED
tcp 0 0 98505b225dd4:58728 mm-770-postgres-1.mm-770_default:5432 ESTABLISHED
tcp 0 0 98505b225dd4:58758 mm-770-postgres-1.mm-770_default:5432 ESTABLISHED
tcp 0 0 98505b225dd4:58748 mm-770-postgres-1.mm-770_default:5432 ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 3 [ ] STREAM CONNECTED 62486324 /tmp/plugin2943161274
unix 3 [ ] STREAM CONNECTED 62486310
unix 3 [ ] STREAM CONNECTED 62485360
unix 3 [ ] STREAM CONNECTED 62485344
unix 3 [ ] STREAM CONNECTED 62486312 /tmp/plugin4011823926
unix 3 [ ] STREAM CONNECTED 62485369 /tmp/plugin2211775106
unix 3 [ ] STREAM CONNECTED 62486337
unix 3 [ ] STREAM CONNECTED 62486338 /tmp/plugin1169520782
unix 3 [ ] STREAM CONNECTED 62485328
unix 3 [ ] STREAM CONNECTED 62485368
unix 3 [ ] STREAM CONNECTED 62485315 /tmp/plugin471179159
unix 3 [ ] STREAM CONNECTED 62485361 /tmp/plugin1627926240
To do that, you can install the busybox-static
package on your host system (or compile your own statically linked busybox binary with all the tools you need) and map it into the container by modifying the volumes in your docker-compose.yml
file (see last line of the volumes section)
volumes:
- ${MATTERMOST_CONFIG_PATH}:/mattermost/config:rw
- ${MATTERMOST_DATA_PATH}:/mattermost/data:rw
- ${MATTERMOST_LOGS_PATH}:/mattermost/logs:rw
- ${MATTERMOST_PLUGINS_PATH}:/mattermost/plugins:rw
- ${MATTERMOST_CLIENT_PLUGINS_PATH}:/mattermost/client/plugins:rw
- ${MATTERMOST_BLEVE_INDEXES_PATH}:/mattermost/bleve-indexes:rw
- /bin/busybox:/bin/busybox:ro