I have a docker container inside which I have jar file that is of my springBoot application . How can I overwrite the application.property file of my app. Suppose if I want to change datasource url ,how can I do that through commandline?
docker ps
and note the initials of id of your container.docker exec -it <id> <bash or sh>
, you will be inside your running container.You can't restart the primary process (PID 1). For that usecase you'll need external volume and restart the container on property file change.
docker volume create vol1
, you will get /var/lib/docker/volumes/vol1/sudo chgrp 1001 /var/lib/docker/volumes/vol1/_data
sudo chmod g+w /var/lib/docker/volumes/vol1/_data
sudo ls -al /var/lib/docker/volumes/vol1/
. They should be: drwxrwxr-x
docker run -d --name=webApp1 --mount source=vol1,destination=/path/to/app -p port:port name
/var/lib/docker/volumes/vol1/_data/
and restart container: docker restart container_name
Disclaimer: Replacing properties file outside jar is not considered a good practice and is highly discouraged. So, these steps are only recommended for testing.