# Docker Optimize Approaches
###### tags: `Infrastructure`
## Docker Squash
### To Squash existed docker image, the procedures are as follows:
1. Install docker-squash tool:
```sh=
pip install docker-squash
```
2. Run docker-squash command:
```sh=
~/.local/bin/docker-squash --tag <new_docker_image_tag> <target_docker_image_tag>
```
### To squash a docker image built by Dockerfile, the procedures are as follows:
1. Change the Docker Daemon Settings:
```sh=
vim /etc/docker/daemon.json
```
Add the following text in the json file:
```
"experimental": true
```
Restart docker after the setting change:
```sh=
systemctl restart docker
```
2. `--squash` in docker build:
```sh=
docker build -t <docker_image_tag> --squash .
```