Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docker_management [2019/10/18 11:04] – external edit 127.0.0.1 | docker_management [2020/01/10 19:24] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====Overview==== | + | =====Overview===== |
In order to connect to docker, you should firstly know the name of the docker container. This can be obtained as follows: | In order to connect to docker, you should firstly know the name of the docker container. This can be obtained as follows: | ||
Line 32: | Line 32: | ||
[root@tain-cx-uatdkrdb1 ~]# docker exec -it cas1 /bin/bash | [root@tain-cx-uatdkrdb1 ~]# docker exec -it cas1 /bin/bash | ||
root@46fac822cffe:/# | root@46fac822cffe:/# | ||
+ | </ | ||
+ | |||
+ | =====File Migration with Mongo===== | ||
+ | Migration to and from the docker is done rather easily, even when you have to export a database or so: | ||
+ | |||
+ | |||
+ | ====Export collection==== | ||
+ | The export from Mongo is done via the standard utils like: mongoexport, | ||
+ | |||
+ | <sxh bash> | ||
+ | [root@tpb-mts-stdkr1 ~]# docker container ls | ||
+ | CONTAINER ID IMAGE COMMAND | ||
+ | 0ac74afee7b7 | ||
+ | c188736759e9 | ||
+ | 18e980dee75c | ||
+ | 8385665052a3 | ||
+ | e03d9bc636c5 | ||
+ | e4031dbf6b08 | ||
+ | 667870179b38 | ||
+ | 5d37f142d32b | ||
+ | (reverse-i-search)`': | ||
+ | </ | ||
+ | |||
+ | Then we can connect to it as follows: | ||
+ | |||
+ | <sxh bash> | ||
+ | [root@tpb-mts-stdkr1 ~]# docker exec -it 8385665052a3 /bin/bash | ||
+ | </ | ||
+ | |||
+ | And then we can connect to the mongo, if we want to: | ||
+ | |||
+ | <sxh bash> | ||
+ | root@8385665052a3:/# | ||
+ | MongoDB shell version v4.0.4 | ||
+ | connecting to: mongodb:// | ||
+ | Implicit session: session { " | ||
+ | MongoDB server version: 4.0.4 | ||
+ | Server has startup warnings: | ||
+ | 2020-01-09T01: | ||
+ | 2020-01-09T01: | ||
+ | 2020-01-09T01: | ||
+ | 2020-01-09T01: | ||
+ | 2020-01-09T01: | ||
+ | 2020-01-09T01: | ||
+ | 2020-01-09T01: | ||
+ | --- | ||
+ | Enable MongoDB' | ||
+ | metrics about your deployment (disk utilization, | ||
+ | |||
+ | The monitoring data will be available on a MongoDB website with a unique URL accessible to you | ||
+ | and anyone you share the URL with. MongoDB may use this information to make product | ||
+ | improvements and to suggest MongoDB products and deployment options to you. | ||
+ | |||
+ | To enable free monitoring, run the following command: db.enableFreeMonitoring() | ||
+ | To permanently disable this reminder, run the following command: db.disableFreeMonitoring() | ||
+ | --- | ||
+ | |||
+ | > | ||
+ | </ | ||
+ | |||
+ | |||
+ | Export of the database, as said again, is done with the standard utils: | ||
+ | <sxh bash> | ||
+ | root@8385665052a3:/# | ||
+ | 2020-01-10T10: | ||
+ | 2020-01-10T10: | ||
+ | root@8385665052a3:/# | ||
+ | </ | ||
+ | |||
+ | And then we can copy it to the main machine: | ||
+ | |||
+ | <sxh bash> | ||
+ | root@8385665052a3:/# | ||
+ | [root@tpb-mts-stdkr1 ~]# | ||
+ | [root@tpb-mts-stdkr1 ~]# | ||
+ | [root@tpb-mts-stdkr1 ~]# docker cp 8385665052a3: | ||
+ | [root@tpb-mts-stdkr1 ~]# ls -lart | ||
+ | total 784672 | ||
+ | -rw-r--r--. | ||
+ | -rw-r--r--. | ||
+ | -rw-r--r--. | ||
+ | -rw-r--r--. | ||
+ | drwxr-----. | ||
+ | drwx------. | ||
+ | drwx------. | ||
+ | -rw-r--r--. | ||
+ | -rw-r--r--. | ||
+ | -rw-r--r--. | ||
+ | dr-xr-xr-x. 18 root root 239 Jun 19 2019 .. | ||
+ | drwxr-xr-x. | ||
+ | drw-r--r--. | ||
+ | drwxr-xr-x. | ||
+ | -rw-r--r--. | ||
+ | drwxr-xr-x. 11 root root 4096 Aug 21 13:25 net.box | ||
+ | -rw-r--r--. | ||
+ | drwxr-xr-x. | ||
+ | drw-r--r--. | ||
+ | drwxr-xr-x. | ||
+ | -rw-r--r--. | ||
+ | -rw-r--r--. | ||
+ | drwx------. | ||
+ | -rw-------. | ||
+ | -rwxr-xr-x. | ||
+ | -rw-r--r--. | ||
+ | </ | ||
+ | |||
+ | |||
+ | We can also perform couple operations like, exchange the BAC -> DT | ||
+ | <sxh bash> | ||
+ | sed ' | ||
+ | </ | ||
+ | |||
+ | We can also remove the _id column as follows: | ||
+ | |||
+ | <sxh bash> | ||
+ | sed -i '/" | ||
+ | </ | ||
+ | |||
+ | And we can take it back: | ||
+ | <sxh bash> | ||
+ | docker cp dt_procedures.json 8385665052a3: | ||
</ | </ |