Why can't Docker find my sql file to import? - sql

I have a SQL file I'm trying to import into a local docker instance. I'm running the following command:
docker exec -i 868b7935cc37 ../my.file.sql -u {user} --password={password} {dbName}
I'm getting the following error back when I run it:
OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: \"../my.file.sql\": stat ../my.file.sql: no such file or directory": unknown
I'm only one directory away from the file, hence the ../ in the command. I spoke with the person who gave me the file and the username, password and name are all correct. None of the names, passwords, etc. contain any special characters.
I feel like I'm right there. I don't know why I'm getting the no such file or directory error.
Any and all help is appreciated!
docker inspect gives me
[
{
"Id": "868b7935cc371a0eef47e84a7ffbddb99b03cfc93e735af31e5b5754680c1f98",
"Created": "2018-11-15T20:11:44.9362404Z",
"Path": "docker-entrypoint.sh",
"Args": [
"mysqld"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 4819,
"ExitCode": 0,
"Error": "",
"StartedAt": "2018-11-23T23:15:52.5735445Z",
"FinishedAt": "2018-11-21T01:52:31.3103165Z"
},
"Image": "sha256:583a6e3a3c98793a6c8a3b09d291b574da66f7e1fba6ebfebe3e93c88c3b443a",
"ResolvConfPath": "/var/lib/docker/containers/868b7935cc371a0eef47e84a7ffbddb99b03cfc93e735af31e5b5754680c1f98/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/868b7935cc371a0eef47e84a7ffbddb99b03cfc93e735af31e5b5754680c1f98/hostname",
"HostsPath": "/var/lib/docker/containers/868b7935cc371a0eef47e84a7ffbddb99b03cfc93e735af31e5b5754680c1f98/hosts",
"LogPath": "/var/lib/docker/containers/868b7935cc371a0eef47e84a7ffbddb99b03cfc93e735af31e5b5754680c1f98/868b7935cc371a0eef47e84a7ffbddb99b03cfc93e735af31e5b5754680c1f98-json.log",
"Name": "/dmr_mysql_1",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"dmr_local_mysql_data:/var/lib/mysql:rw",
"dmr_local_mysql_data_backups:/backups:rw"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "dmr_default",
"PortBindings": {
"3306/tcp": [
{
"HostIp": "",
"HostPort": "3306"
}
]
},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": [],
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/asound",
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/830398a5558d1451a520a7219971cfb6f869cfc7aa149373eab77287c2924ee4-init/diff:/var/lib/docker/overlay2/d6fbcced29e35b61a9bb5a8db9cec8c561fdcba5b52a61c62af886de180aa93a/diff:/var/lib/docker/overlay2/289d826020070599fe59d4171f40bfcfc41de1bbefa29bcc4cfd0bc0ab5ebb3c/diff:/var/lib/docker/overlay2/05572289cc7498d3d29d09d0b9745c0387c56ef06919ef27517c9131a585a895/diff:/var/lib/docker/overlay2/eed1357572b7a67729f776846e8109fa9493e0083d88bb3edeb2c95410bfa2b4/diff:/var/lib/docker/overlay2/8163d89b53f562d5476ffc8ccabdcb6a935ee932b2544f0d42ada9650b67eb46/diff:/var/lib/docker/overlay2/8ea425a1f09814f6e6f3f9d8f887c0829b2151e359425ea985792a75e65acd90/diff:/var/lib/docker/overlay2/ae06aa0cbb069d340970beb76ad8b278ac4b4f97eaceb1f3b36cb4ba15a2128c/diff:/var/lib/docker/overlay2/16350f1b36b1eb496286e5ad4cdea02f9931d33a6869a6105da766e40793d81a/diff:/var/lib/docker/overlay2/305da8336df57edf64806244981141bd6a05b168653a48f97223e7da0a3ac477/diff:/var/lib/docker/overlay2/2265f0da439e923b98007d292dda922f3a90298bb879c07f2f41afa66c971c7b/diff:/var/lib/docker/overlay2/b5e59e46468f95a1d243b6c99b7421b41715f7ad11bda4095901244a6552bbb9/diff:/var/lib/docker/overlay2/76fdb756320d579aed7713e27b4760a5266fcfde5358903d9e4351d9c77a4b9d/diff:/var/lib/docker/overlay2/58952f226dee428fecc6cf23f45e39b4084f10c6214f3ded03ebd87a250318bd/diff:/var/lib/docker/overlay2/7f03ca1e222e9ee48d8332e6ec830cb0a2a7a27167d2698847d41d3f18c47bd3/diff",
"MergedDir": "/var/lib/docker/overlay2/830398a5558d1451a520a7219971cfb6f869cfc7aa149373eab77287c2924ee4/merged",
"UpperDir": "/var/lib/docker/overlay2/830398a5558d1451a520a7219971cfb6f869cfc7aa149373eab77287c2924ee4/diff",
"WorkDir": "/var/lib/docker/overlay2/830398a5558d1451a520a7219971cfb6f869cfc7aa149373eab77287c2924ee4/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "volume",
"Name": "dmr_local_mysql_data_backups",
"Source": "/var/lib/docker/volumes/dmr_local_mysql_data_backups/_data",
"Destination": "/backups",
"Driver": "local",
"Mode": "rw",
"RW": true,
"Propagation": ""
},
{
"Type": "volume",
"Name": "dmr_local_mysql_data",
"Source": "/var/lib/docker/volumes/dmr_local_mysql_data/_data",
"Destination": "/var/lib/mysql",
"Driver": "local",
"Mode": "rw",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "868b7935cc37",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {},
"33060/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"MYSQL_DATABASE=dmr",
"MYSQL_USER=dmr",
"MYSQL_PASSWORD=dmr",
"MYSQL_ROOT_PASSWORD=dmr",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.7",
"MYSQL_MAJOR=5.7",
"MYSQL_VERSION=5.7.24-1debian9"
],
"Cmd": [
"mysqld"
],
"ArgsEscaped": true,
"Image": "dmr_mysql",
"Volumes": {
"/backups": {},
"/var/lib/mysql": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "ffc27388c47a8468694fe5412bb06e3dda7a7b083d378fba1ab57eace2b3628e",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "dmr",
"com.docker.compose.service": "mysql",
"com.docker.compose.version": "1.22.0"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "cbccae535b05d954c1592710bb808814a87bcfbee6617fd1fb0a8f44561faec7",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"3306/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "3306"
}
],
"33060/tcp": null
},
"SandboxKey": "/var/run/docker/netns/cbccae535b05",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"dmr_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"868b7935cc37",
"mysql"
],
"NetworkID": "eaf16cd4854d6bcb607ca7598c5337d42b917164404de82f873b9567ab480df7",
"EndpointID": "c98e525c7c4f22e5bfb7b6041a2f94fbf81561f518d2a6b550768ef6c32e57d5",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02",
"DriverOpts": null
}
}
}
}
]

I believe the problem is a misunderstanding of how docker exec works. If you think of your container as a remote machine, and docker exec as a command you run on your local machine that will cause the remote machine to execute some command installed on the remote machine, it may become more clear
Right now it looks like you have a file on your local machine (outside the container) and you're passing it as the command you wish the remote machine(inside the container) to run, but the file is on your local machine, not the remote so even if it could be processed (docker help page says it must be an executable file- is an sql file executable in this context?) the file isn't on the machine that is going to process it.
Calling docker exec and passing a file reference of a file outside the container, doesn't cause the local file to be sent into the container and executed inside
As such, I think you'll have to do something more like
docker cp ../myfile.sql DOCKERCONTAINERNAME:/root/myfile.sql
To copy the file into the container and then something like:
docker exec DOCKERCONTAINERNAME mysqlimporttool -u mysqluser -p pass /root/myfile.sql
To have docker launch the in-container import tool for you and pass the arguments you specified. That tool will start up inside the container, and process the file you copied into the container in the first step

You don't need docker exec to interact with servers running in containers. Just use the ordinary client programs you'd normally use to talk to them.
For instance, if you launched the database container, publishing the normal MySQL port, as as
docker run -p3306:3306 ... mysql
then you could run your script by installing the mysql command-line client, and then running
mysql -h 127.0.0.1 ../my.file.sql -u {user} --password={password} {dbName}
If you've configured your Docker to require root permission to access it (a very reasonable setup) then this has the additional advantage of not requiring sudo just to run it.

Related

Stack in Portainer is limited, although it is created with the Portainer API

I am trying to deploy a stack via Portainer API. This is working. But the Portainer UI tells me, that the access to this stack limited, although I have created it with Portainer.
If I look at the response after deploying the stack via API, I see that there is a part called "Resource Control".
{
"Id": 12,
"Name": "test",
"Type": 1,
"EndpointId": 2,
"SwarmId": "MySwarm",
"EntryPoint": "docker-compose.yml",
"Env": null,
"ResourceControl": {
"Id": 11,
"ResourceId": "2_test",
"SubResourceIds": [],
"Type": 6,
"UserAccesses": [],
"TeamAccesses": [],
"Public": false,
"AdministratorsOnly": true,
"System": false
},
"Status": 1,
"ProjectPath": "/data/compose/12",
"CreationDate": 1674110389,
"CreatedBy": "admin",
"UpdateDate": 0,
"UpdatedBy": "",
"AdditionalFiles": null,
"AutoUpdate": null,
"GitConfig": null,
"FromAppTemplate": false,
"Namespace": "",
"IsComposeFormat": false}
Is this the reason for the limited access on the UI? And is there any way to deploy a stack via API and have full access?

Docker: Cannot launch .Net Core 3.1 Web Api on browser after docker run

I'm new to Docker and, as a start, I'm trying to accomplish a basic task, dockerize a .Net Core 3.1 Web Api and run it from the command line (not From Visual Studio where it actually works).
I create my project image using the following Dockerfile and with the next command:
docker build -t concepttest_crud1 .
Dockerfile (created by Visual Studio):
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["Gfi_ConceptTest_CRUD1/Gfi_ConceptTest_CRUD1.csproj", "Gfi_ConceptTest_CRUD1/"]
RUN dotnet restore "Gfi_ConceptTest_CRUD1/Gfi_ConceptTest_CRUD1.csproj"
COPY . .
WORKDIR "/src/Gfi_ConceptTest_CRUD1"
RUN dotnet build "Gfi_ConceptTest_CRUD1.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Gfi_ConceptTest_CRUD1.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Gfi_ConceptTest_CRUD1.dll"]
4) I run my image with the following command:
docker run -d -p 8080:44390 --name crud1 concepttest_crud1
where 44390 is the port I have my api configured on in Visual Studio.
When debugging I use to access the api through:
https://localhost:44390/api/Authors
5) I'm trying to test my dockerized api in Chrome with the next url:
https://localhost:8080/api/Authors
to no avail. No matter with url I try, my api won't start when the docker run command executes with no errors.
docker ps output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8df6c92c6678 concepttest_crud1 "dotnet Gfi_ConceptT…" 22 minutes ago Up 22 minutes 0.0.0.0:8080->44390/tcp crud1
docker images output:
REPOSITORY TAG IMAGE ID CREATED SIZE
concepttest_crud1 latest 878e4c4845f6 About an hour ago 228MB
<none> <none> 36a29990113c About an hour ago 1GB
In the Docker images output I don't know why I see two images (a second with no name) when I expect only one.
I've also tried http://192.168.99.100:8080/api/Authors but it is not working either.
Edit 1: Adding docker inspect.
[
{
"Id": "0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57",
"Created": "2019-12-23T12:30:06.3947619Z",
"Path": "dotnet",
"Args": [
"Gfi_ConceptTest_CRUD1.dll"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 83477,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-12-23T12:30:08.9701219Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:92b9217abf5dc6a7fc6c10aac2ac5549d6873adfc1b3ed30264d6e1fd4a971c7",
"ResolvConfPath": "/var/lib/docker/containers/0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57/hostname",
"HostsPath": "/var/lib/docker/containers/0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57/hosts",
"LogPath": "/var/lib/docker/containers/0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57/0f0bf4b4de30ef5dd222016db639abe45e5e70bc25270b74df45eec64e319b57-json.log",
"Name": "/crud1",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"443/tcp": [
{
"HostIp": "",
"HostPort": "8080"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
28,
165
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/3781dd694db551736c551397e9a0834ebd6fa653e0b78b6d6244e15ef7b8c291-init/diff:/var/lib/docker/overlay2/025232b693c4a6470e0b26e5302e5165757dbc4a44d5af5b7b8aa8dacd77ee03/diff:/var/lib/docker/overlay2/bcca2356fe199bbaa471c3590a3f55df343eecd84899cf570197d97ed8111d95/diff:/var/lib/docker/overlay2/5f2d77acbd50bc4a8cde011128fb43b2a0cff888e716c5ba882d4dd906bc1901/diff:/var/lib/docker/overlay2/ca57ac72ac1d48b622745bb473fd71c18d67392b02cdf938835f05cf9b547681/diff:/var/lib/docker/overlay2/0b894b31b26df6e40b57a86dc66bbd4eda71d0ebf6d5755c4c43bc296e9a24de/diff:/var/lib/docker/overlay2/b6ca0109d2718605ccba2585e52ae1718cbecd2fcd62197f1f7fd505cf2be358/diff:/var/lib/docker/overlay2/e0ff62d02fe725053674ce9e3b59a4004c101fd2e98f919e5037a412f1c3a4e8/diff",
"MergedDir": "/var/lib/docker/overlay2/3781dd694db551736c551397e9a0834ebd6fa653e0b78b6d6244e15ef7b8c291/merged",
"UpperDir": "/var/lib/docker/overlay2/3781dd694db551736c551397e9a0834ebd6fa653e0b78b6d6244e15ef7b8c291/diff",
"WorkDir": "/var/lib/docker/overlay2/3781dd694db551736c551397e9a0834ebd6fa653e0b78b6d6244e15ef7b8c291/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "0f0bf4b4de30",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"443/tcp": {},
"8080/tcp": {}
},
"Tty": true,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"ASPNETCORE_URLS=http://+:80",
"DOTNET_RUNNING_IN_CONTAINER=true"
],
"Cmd": null,
"Image": "crud1",
"Volumes": null,
"WorkingDir": "/app",
"Entrypoint": [
"dotnet",
"Gfi_ConceptTest_CRUD1.dll"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "ed889f3303ca17ad4e79ae917d8b17c5e590af502adb8049dbd7e0fcd46b323c",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"443/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
],
"8080/tcp": null
},
"SandboxKey": "/var/run/docker/netns/ed889f3303ca",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "001cd49640c4211e5eeb1eedacedd6de07022cc3362acaca59b82f0e537f6238",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "ccea227190a1f04d0043015cf3d9932ba41f4a96dfb9bc2a175a06483a9ca66e",
"EndpointID": "001cd49640c4211e5eeb1eedacedd6de07022cc3362acaca59b82f0e537f6238",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]
Edit 2: Added curl.
docker exec -it 0f0bf4b4de30 /bin/bash . root#4237f947b2b0:/app# curl https://localhost:8080/api/Authors
.: .: Is a directory
Edit 3: New curl
docker exec -it 0f0bf4b4de30 /bin/bash . root#4237f947b2b0:/app# curl https://localhost/api/Authors
.: .: Is a directory
In my case it was due to having SSL enabled inthe project, but after removing everything related to https it started working as expected.
Having SSL enabled implies installing a SSL certificate inside the docker container and enabling it, things I wasn't able to do as I don't have a certificate and I'm just learning docker.
Steps I've done:
In Startup.cs I've disabled https redirection
//app.UseHttpsRedirection();
And in project properties under "Debug" section I unchecked "Enable SSL".
Then I was able to run the container as expected.

How to get list of Users under a certain Manager/Approver in Coupa API?

I'm lost and I'm hoping that someone may have worked on this before.
So Coupa has its API:
https://coupadocs.atlassian.net/wiki/display/integrate/Users+API
I was able to retrieve user information together with the corresponding manager. Sample response:
https://unknownserver-test.coupahost.com/api/users?employee-number=10003323
[
{
"id": 2756,
"created-at": "2017-03-30T09:29:19-05:00",
"updated-at": "2017-03-31T04:30:53-05:00",
"login": "user1.user1",
"email": "staging23#coupa.com",
"purchasing-user": false,
"expense-user": false,
"sourcing-user": false,
"inventory-user": false,
"employee-number": "10003323",
"phone-work": null,
"phone-mobile": null,
"firstname": "user1",
"lastname": "user1",
"fullname": "user1 user1",
"api-user": false,
"active": false,
"salesforce-id": null,
"account-security-type": 0,
"authentication-method": "coupa_credentials",
"sso-identifier": null,
"default-locale": null,
"default-account": null,
"business-group-security-type": null,
"edit-invoice-on-quick-entry": false,
"avatar-thumb-url": null,
"mention-name": "user1user1",
"company-employee-id": "10003323",
"netsuite-employee-id": "10003323",
"subsidiary": {
"id": 1592,
"external-ref-num": null,
"external-ref-code": "company North America:1"
},
"job-title": {
"id": 2591,
"external-ref-num": null,
"external-ref-code": "VP, Sales"
},
"employee-type": "",
"default-expense-region": "",
"default-geo-spend": "",
"notes": "",
"exclude-from-autosarf": "",
"roles": [
{
"id": 10,
"name": "Expense User"
}
],
"manager": {
"id": 838,
"login": "john.doe",
"email": "staging#coupa.com"
},
"default-currency": {
"id": 1,
"code": "USD"
},
"department": {
"id": 342,
"name": "Sales - Exec:176"
},
"expenses-delegated-to": [],
"can-expense-for": [],
"content-groups": [],
"account-groups": [],
"approval-groups": [],
"working-warehouses": [],
"inventory-organizations": [],
"created-by": {
"id": 2748,
"login": "user1 creator",
"email": "user1.creator#company.com"
},
"updated-by": {
"id": 2748,
"login": "user1 creator",
"email": "user1.creator#company.com"
}
}
]
What I've tried are these:
https://unknownserver-test.coupahost.com/api/users?user[manager][id]=838&return_object=shallow
https://unknownserver-test.coupahost.com/api/users?manager[id]=838&return_object=shallow
https://unknownserver-test.coupahost.com/api/users?users[user][manager][id]=838&return_object=shallow
https://{{URL PREFIX}}.{{HOST}}.com/api/users?manager_id=838&return_object=shallow
If you only need the IDs of the users, you'd get better performance with return_object=limited
If there are more than 50 users returned, you'll have to paginate with the offset query param.

Access subscription details with Stripes Webhooks PHP

I haven't been able to find any details for this with PHP, so I am hoping somebody can help me complete this script?
I am searching for the Subscription details from the Stripe API Webhook event. The event I am working on is invoice.payment_succeeded although I am struggling to access the subscription information from this. Here is the test event in full:
{
"id": "evt_19HdmRL346436RYAmvgxkr",
"object": "event",
"api_version": "2016-07-06",
"created": 1479580899,
"data": {
"object": {
"id": "in_19HdmRLniq434634643dO2gU",
"object": "invoice",
"amount_due": 700,
"application_fee": null,
"attempt_count": 1,
"attempted": true,
"charge": "ch_19Hdm3463464365IDDXX",
"closed": true,
"currency": "gbp",
"customer": "315464619",
"date": 1479580899,
"description": null,
"discount": null,
"ending_balance": 0,
"forgiven": false,
"lines": {
"object": "list",
"data": [
{
"id": "sub_9apRC346346CMNg",
"object": "line_item",
"amount": 700,
"currency": "gbp",
"description": null,
"discountable": true,
"livemode": false,
"metadata": {
"website_ref": "Z8ckRo2x",
"user_id": "1"
},
"period": {
"start": 1479580899,
"end": 1482172899
},
"plan": {
"id": "AdFree",
"object": "plan",
"amount": 700,
"created": 1479261871,
"currency": "gbp",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"name": "AdFree",
"statement_descriptor": "SNAPPYSITES ADFREE",
"trial_period_days": null
},
"proration": false,
"quantity": 1,
"subscription": null,
"type": "subscription"
}
],
"has_more": false,
"total_count": 1,
"url": "/v1/invoices/in_19HdmRLn34353465dO2gU/lines"
},
"livemode": false,
"metadata": {},
"next_payment_attempt": null,
"paid": true,
"period_end": 1479580899,
"period_start": 1479580899,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": null,
"subscription": "sub_9a2552OA5553MNg",
"subtotal": 700,
"tax": null,
"tax_percent": null,
"total": 700,
"webhooks_delivered_at": null
}
},
"livemode": false,
"pending_webhooks": 1,
"request": "req_9apRx9555ZVm55",
"type": "invoice.payment_succeeded"
}
I am currently listening with this unfinished script:
$input = #file_get_contents("php://input");
$event_json = json_decode($input);
$event_id = $event_json->id;
$event = \Stripe\Event::retrieve($event_id);
if($event->type == 'invoice.payment_succeeded'){
$invoice = $event->data->object;
$subscription = $invoice->lines->data->plan;
$customer = \Stripe\Customer::retrieve($invoice->customer);
print_r($subscription);
}
Unfortunately I'm not getting any response from the $subscription array. And I have attempted various methods, such as; $subscription = $invoice->plan; or $subscription = $invoice->data->plan; etc...
I do receive data for $invoice & $customer so I know they both function correctly. My main focus is to retrieve the Metadata information:
"metadata": {
"website_ref": "Z8ckRo2x",
"user_id": "1"
}
So I know which account this payment relates to. Hoping somebody might know what I'm doing wrong.
Have you tried $invoice->lines->data->Metadata->website_ref to get the metadata you are after?
Your Invoice consists of a list of subscriptions, in this case just 1. Each subscription is a result of the user selecting a plan. The metadata is stored at the subscription level as it's specific for the customer, not on the plan.

Unable to connect to dockerized redis instance from outside docker

I have the latest docker installation (without boot2docker) and I am unable to connect to a dockerized redis instance running locally. Could you please tell me what I'm doing wrong here?
Created the docker, mapped port 6379 to 127.0.0.1:6379
bash-3.2$ docker run -p 127.0.0.1:6379:6379 --name webmonitor-redis -d redis
3291541d58ab16c362f9e0cd7017d179c0bc9aef3a1323e79f1e1ca075e171c9
docker ps output:
bash-3.2$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3291541d58ab redis "/entrypoint.sh redis" 14 seconds ago Up 6 seconds 127.0.0.1:6379->6379/tcp webmonitor-redis
Tried connecting from outside container (but the same host where container is running), connection failed:
bash-3.2$ ./src/redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit
It works if I try to connect from another container though..
bash-3.2$ docker run -it --link webmonitor-redis:redis --rm redis sh -c 'exec redis-cli -h "$REDIS_PORT_6379_TCP_ADDR" -p "$REDIS_PORT_6379_TCP_PORT"'
172.17.0.8:6379>
Here's the docker inspect for the container:
bash-3.2$ docker inspect 3291541d58ab
[
{
"Id": "3291541d58ab16c362f9e0cd7017d179c0bc9aef3a1323e79f1e1ca075e171c9",
"Created": "2015-10-03T15:48:17.818355794Z",
"Path": "/entrypoint.sh",
"Args": [
"redis-server"
],
"State": {
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 7769,
"ExitCode": 0,
"Error": "",
"StartedAt": "2015-10-03T15:48:17.954436198Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "2f2578ff984f013c9a5d6cbb6fe061ed3f73a17380a4c9b53b76d4b8da3eda7d",
"NetworkSettings": {
"Bridge": "",
"EndpointID": "b787e46d1219f36d4f1b1ea35c5f750f7174221137fb01889a26a3bc1e1c6aee",
"Gateway": "172.17.42.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"HairpinMode": false,
"IPAddress": "172.17.0.8",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:08",
"NetworkID": "30176c9c7c14a6a052af784014832a0c52b5966089d7bcfe535041569e6bb1c9",
"PortMapping": null,
"Ports": {
"6379/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "6379"
}
]
},
"SandboxKey": "/var/run/docker/netns/3291541d58ab",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null
},
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/3291541d58ab16c362f9e0cd7017d179c0bc9aef3a1323e79f1e1ca075e171c9/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/3291541d58ab16c362f9e0cd7017d179c0bc9aef3a1323e79f1e1ca075e171c9/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/3291541d58ab16c362f9e0cd7017d179c0bc9aef3a1323e79f1e1ca075e171c9/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/3291541d58ab16c362f9e0cd7017d179c0bc9aef3a1323e79f1e1ca075e171c9/3291541d58ab16c362f9e0cd7017d179c0bc9aef3a1323e79f1e1ca075e171c9-json.log",
"Name": "/webmonitor-redis",
"RestartCount": 0,
"Driver": "aufs",
"ExecDriver": "native-0.2",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LxcConf": [],
"Memory": 0,
"MemorySwap": 0,
"CpuShares": 0,
"CpuPeriod": 0,
"CpusetCpus": "",
"CpusetMems": "",
"CpuQuota": 0,
"BlkioWeight": 0,
"OomKillDisable": false,
"MemorySwappiness": -1,
"Privileged": false,
"PortBindings": {
"6379/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "6379"
}
]
},
"Links": null,
"PublishAllPorts": false,
"Dns": null,
"DnsSearch": null,
"ExtraHosts": null,
"VolumesFrom": null,
"Devices": [],
"NetworkMode": "default",
"IpcMode": "",
"PidMode": "",
"UTSMode": "",
"CapAdd": null,
"CapDrop": null,
"GroupAdd": null,
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"SecurityOpt": null,
"ReadonlyRootfs": false,
"Ulimits": null,
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"CgroupParent": "",
"ConsoleSize": [
0,
0
]
},
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"Mounts": [
{
"Name": "643a80cbd7a50cfd481acc48721b34030c8ce55ba64ac3bc161d5b330c9374d2",
"Source": "/mnt/sda1/var/lib/docker/volumes/643a80cbd7a50cfd481acc48721b34030c8ce55ba64ac3bc161d5b330c9374d2/_data",
"Destination": "/data",
"Driver": "local",
"Mode": "",
"RW": true
}
],
"Config": {
"Hostname": "3291541d58ab",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"6379/tcp": {}
},
"PublishService": "",
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"REDIS_VERSION=3.0.3",
"REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-3.0.3.tar.gz",
"REDIS_DOWNLOAD_SHA1=0e2d7707327986ae652df717059354b358b83358"
],
"Cmd": [
"redis-server"
],
"Image": "redis",
"Volumes": {
"/data": {}
},
"VolumeDriver": "",
"WorkingDir": "/data",
"Entrypoint": [
"/entrypoint.sh"
],
"NetworkDisabled": false,
"MacAddress": "",
"OnBuild": null,
"Labels": {}
}
}
]
Am I missing something here?
make sure the port 6379 on the host is forwarded to port 6379 on docker.
use -p 6379:6379 to fixed the problem:
docker run -d --name redisDev -p 6379:6379 redis
The VM has it's own IP 192.168.99.100 so I was able to connect by binding to 192.168.99.100:6379:6379 and then connecting as below.
0c4de9a25467:redis-stable electron$ ./src/redis-cli -h 192.168.99.100
192.168.99.100:6379>
docker run -p 6379:6379 -host 0.0.0.0 --name webmonitor-redis -d redis