Tuesday, October 20, 2020

to copy a file from a docker container to host

shell>  docker cp <containerId>:/file/path/within/container /host/path/target


where to get your docker container id? 


shell> docker ps


and you will get to see similar output in your command prompt as following:


CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                    NAMES

fff29505492e        localstack_redis:latest        "docker-entrypoint.s…"   2 weeks ago         Up 8 hours          0.0.0.0:6379->6379/tcp   gifted_wozniak

2e99dabb5692        localstack_mysql:latest        "docker-entrypoint.s…"   2 weeks ago         Up 8 hours          0.0.0.0:3306->3306/tcp   vibrant_chandrasekhar

7438b2ef7cbb        localstack_prom2teams:latest   "sh prom2teams_start…"   2 weeks ago         Up 8 hours          8089/tcp                 cranky_merkle


Case : to copy a file in your docker location such as /tmp/target.txt from localstack_mysql:latest. 

shell> docker cp 2e99dabb5692:/tmp/target.txt c:/tmp/

Tuesday, June 16, 2020

To Delete all data from Kafka Topic - in a manual way

to delete the data inside the topic:
Steps:
  1. stop the Kafka server & zookeeper
  2. go into this folder - > gerrit\backend\docker\zk-single-kafka-single\kafka1\data
  3. and delete all the "XXX" topic folder 
  4. start the kafka & zookeeper 

Friday, May 22, 2020

Java: To read file from JAR file classpath

if the *.xml file and .config or even some other file are located in different jars, make sure you use

resource.getInputStream()

NOT

resource.getFile()

when you are loading a file from inside a jar.