Can't connect to local file on disc when deployed on Docker

What am I doing wrong?


(base) Arghyas-MBP:~ arghyaroy$ docker run -i --init \

--name singlestore-ciab \
-e LICENSE_KEY=$LICENSE_KEY \
-e ROOT_PASSWORD=$ROOT_PASSWORD \
-p 3306:3306 -p 8080:8080 \
singlestore/cluster-in-a-box

2021-09-14 04:38:56.577525 Initializing SingleStore Cluster in a Box
2021-09-14 04:38:56.577605 Creating…
2021-09-14 04:38:56.883591 Done.
2021-09-14 04:38:56.883648 Configuring…
2021-09-14 04:38:57.587617 Done.
2021-09-14 04:38:57.587672 Bootstrapping…
2021-09-14 04:39:02.858426 Done.
2021-09-14 04:39:02.858503 Configuring Toolbox…
2021-09-14 04:39:02.899698 Done.

Successful initialization!

To start the cluster:
docker start (CONTAINER_NAME)

To stop the cluster (must be started):
docker stop (CONTAINER_NAME)

To remove the cluster (all data will be deleted):
docker rm (CONTAINER_NAME)

(base) Arghyas-MBP:~ arghyaroy$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
(base) Arghyas-MBP:~ arghyaroy$ docker start singlestore-ciab
singlestore-ciab
(base) Arghyas-MBP:~ arghyaroy$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3048596335f9 singlestore/cluster-in-a-box “/startup” 38 seconds ago Up 3 seconds 0.0.0.0:3306->3306/tcp, 0.0.0.0:8080->8080/tcp, 3307/tcp singlestore-ciab
(base) Arghyas-MBP:~ arghyaroy$ echo $ROOT_PASSWORD
s;ehDYLabJ*iL^w+u:EW
(base) Arghyas-MBP:~ arghyaroy$ docker exec -it singlestore-ciab singlestore
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)
(base) Arghyas-MBP:~ arghyaroy$

Hi, the singlestore client you’re running within the container is mostly a slightly modified version of the mysql client, and expects similar arguments - since you setup a password, you need to specify it in the client:
docker exec -it singlestore-ciab singlestore -p"$ROOT_PASSWORD"

If you’re curious about other options, you can check the help page with:
docker exec -it singlestore-ciab singlestore --help

Since you setup port forwarding when initializing the container, you can also connect directly with mysql if you have it installed, without needing needing docker exec, for example:
mysql -uroot -p$ROOT_PASSWORD

Let us know if you have any other issues!

Thanks Rodrigo! I could login with client and have ensured that my text file is present and readable from /Users/arghyaroy/delete_me/books.txt. However, the Singlestore client is unable to read the location?

singlestore> CREATE PIPELINE library AS LOAD DATA FS ‘/Users/arghyaroy/delete_me/books.txt’ INTO TABLE classic_books FIELDS TERMINATED BY ‘,’;
ERROR 1933 (HY000): Cannot get source metadata for a pipeline. File or directory ‘/Users/arghyaroy/delete_me/books.txt’ does not exist


(base) Arghyas-MacBook-Pro:~ arghyaroy$ cat /Users/arghyaroy/delete_me/books.txt
The Catcher in the Rye, J.D. Salinger, 1945
Pride and Prejudice, Jane Austen, 1813
Of Mice and Men, John Steinbeck, 1937
Frankenstein, Mary Shelley, 1818
(base) Arghyas-MacBook-Pro:~ arghyaroy$

Hi, here’s a workaround that will help -
Since you’re using a Docker container to run the singlestore client, you’ll need to copy the text file inside the Docker container. The / address in your command refers to the root of your Docker container.
Try the following steps:
mac_terminal> docker cp ‘/Users/arghyaroy/delete_me/books.txt’ 3048596335f9:/tmp
3048596335f9 is the ID of your Docker container.

singlestore> CREATE PIPELINE library AS LOAD DATA FS ‘/tmp/books.txt’ INTO TABLE classic_books  FIELDS TERMINATED BY ‘,’;
singlestore> SELECT * FROM classic_books;
+------------------------+-----------------+------+
| book                   | author          | year |
+------------------------+-----------------+------+
| The Catcher in the Rye |  J.D. Salinger  | 1945 |
| Pride and Prejudice    |  Jane Austen    | 1813 |
| Of Mice and Men        |  John Steinbeck | 1937 |
| Frankenstein           |  Mary Shelley   | 1818 |
+------------------------+-----------------+------+
4 rows in set (0.00 sec)

Let us know, if you face any issues with this solution.

There are a couple ways you can do this. The simplest way to do so is to use the dockerfile ADD command like so:

ADD . /path/inside/docker/container

However, any changes made to this directory on the host after building the dockerfile will not show up in the container. This is because when building a container, docker compresses the directory into a .tar and uploads that context into the container permanently.

The second way to do this is the way you attempted, which is to mount a volume. Due to trying to be as portable as possible you cannot map a host directory to a docker container directory within a dockerfile, because the host directory can change depending on which machine you are running on. To map a host directory to a docker container directory you need to use the -v flag when using docker run.