如何通过Dockerfile中的命令来填充表
我build立(没有错误) mypostgres
图像。 有与postgresql
相关的命令:
RUN /etc/init.d/postgresql start &&\ psql --command "CREATE USER cobrain WITH SUPERUSER PASSWORD 'cobrain';" &&\ createdb -O cobrain datasets &&\ psql --command "CREATE TABLE datasets (id varchar PRIMARY KEY, creation_timestamp bigint, type varchar, owner varchar, datafiles varchar[]);" &&\ psql --command "INSERT INTO datasets (id, creation_timestamp, type, owner, datafiles) VALUES ('111', 1111345, 'MEDICAL', 'Yandex', ARRAY['blood.data'])"
我运行容器:
docker run -p 32779:5432 mypostgres:latest
然后在另一个terminal,我尝试访问postgres服务:
psql -h localhost -p 32779 -U cobrain datasets datasets=# select * from datasets; ERROR: relation "datasets" does not exist
要么
datasets=# \dt; No relations found.
这些消息对我来说很奇怪,因为我在表中创build并插入了值。 如何克服它们,并select
语句?
- 为什么要将数据容器从数据库容器中分离出来比把数据容量从磁盘中分离出来要好呢?
- Docker Windows容器中的Powershell列表过程生成空白列表
- TravisCI泊坞窗权限
- Kubernetes + MySQL:在Kubernetes容器中创build自定义数据库和用户
- 未能解决'kafka:9092':名称或服务未知 – docker / php-rdkafka
- Docker – 应用程序源代码更新
- Django Cookiecutter如何更改生产媒体存储到本地
- docker上的应用程序商店应该在哪上传文件?
- 在PSQLException上运行Grails应用程序失败:此ResultSet被closures