404 error when rebuild docker

Post by Lưu Đại at 29-02-2024

1. Reason

Sometimes when I rebuild docker, some library can't not be downloaded and docker raise 404 error. 
The reason of that is when docker rebuild a container it'll rerun from the first line (from top to bottom) that changed, all line above will be built base on cache. 
For example the command below might cause 404 error because its version is cached and docker may try to fetch those exact lib's version when rebuild, but that version might be deprecated and deleted from its source. 

apt-get install -y build-essential

2. How to fix

We can add option --no-cache to build command so docker will ignore the cache and rebuild from the start. 

3. References