I get "docker: Error response from daemon: OCI runtime create failed" with open_uri in Ruby - ruby

I am getting an error saying "docker: Error response from daemon: OCI runtime create failed" when I give an argument to my Docker image in running.
My application source code follows:
require "open-uri"
require "nokogiri"
crawling_url = ARGV[0]
unless crawling_url
puts "URL to crawl is empty"
exit 1
end
puts crawling_url
page = Nokogiri.HTML(open(crawling_url))
puts page.title
And Dockerfile is:
FROM ruby:2.6
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
WORKDIR /usr/src/app
COPY Gemfile Gemfile.lock ./
RUN gem install bundler
RUN bundle install
COPY . .
CMD ["ruby", "/usr/src/app/crawler.rb"]
The build command I use is:
$ docker build -t crawler .
When I don't give any argument to my script, it works, but when I give one, it doesn't.
$ docker run -it crawler
URL to crawl is empty
$ docker run -it crawler "https://google.com"
docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"https://google.com\": stat https://google.com: no such file or directory": unknown.
ERRO[0001] error waiting for container: context canceled
What's wrong with it?

It worked after I changed CMD to ENTRYPOINT at last.
ENTRYPOINT ["ruby", "/usr/src/app/crawler.rb"]

Related

The command '/bin/sh -c go build -o image_srv .' returned a non-zero code: 2

I am trying to build a docker file using docker-compose. Part of the build is related to go language. When I build the code I get the following error. What could be the issue? How do I fix this error ? Could you please advise? I am new to go language
---> Running in 68f94f330d0b
Removing intermediate container 68f94f330d0b
---> 7a9ca17f7bd7
Step 15/16 : RUN go build -o image_srv .
---> Running in 38fa96ef75d6
# golang.org/x/sys/unix
/go/src/golang.org/x/sys/unix/syscall.go:83:16: undefined: unsafe.Slice
/go/src/golang.org/x/sys/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
/go/src/golang.org/x/sys/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice
The command '/bin/sh -c go build -o image_srv .' returned a non-zero code: 2
You can find appropriate 1.17 tags by going to https://hub.docker.com/_/golang/tags?page=1&name=1.17
Probably golang:1.17.13-alpine will suite your use case
Take note that you may need to delete any existing docker images so that the image can rebuild
# list docker images
$ docker image ls
# delete image foobar
$ docker rmi foobar

yarn deploy give error with Command failed with exit code 1 when running collection-examples-as

I am trying to run the collection-examples-as near example but when I run yarn deploy it gives me the following error
$ near dev-deploy --wasmFile="./contract.wasm"
Starting deployment. Account id: dev-1637744501224-6323200, node:
https://rpc.testnet.near.org, helper: https://helper.testnet.near.org, file:
./contract.wasm
An error occurred
Error: ENOENT: no such file or directory, open './contract.wasm'
[Error: ENOENT: no such file or directory, open './contract.wasm'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: './contract.wasm'
}
error Command failed with exit code 1.
I think the error is it can't find the path to ./contract.wasm so I run yarn build the I tried to deploy it again using yarn deploy but I got another error which is:
$ near dev-deploy --wasmFile="./contract.wasm"
Starting deployment. Account id: dev-1637744501224-6323200, node:
https://rpc.testnet.near.org, helper: https://helper.testnet.near.org, file:
./contract.wasm
An error occurred
Error: Can not sign transactions for account dev-1637744501224-6323200 on network
default, no matching key pair found in
InMemorySigner(MergeKeyStore(UnencryptedFileSystemKeyStore(/home/rasha/.near-
credentials), UnencryptedFileSystemKeyStore(/home/rasha/collection-examples-
as/neardev))).
{
type: 'KeyNotFound',
context: undefined
}
any help or suggestions?
There's an issue with old versions of near-cli and dev-deploy.
As a workaround, you can try running the latest cli directly from your terminal:
near dev-deploy --wasmFile="./contract.wasm" -f
Just check that you installed the latest version of near-cli, currently 2.2.0. You can check your version with near --version.
Be sure to run yarn build first, so you'll have the compiled contract.wasm file.
Note: When you run yarn deploy, it uses the old near-cli version defined in package.json. (probably some old version like 1.6.0)
You might also want to check this GitHub issue (dev-deploy error): https://github.com/near/create-near-app/issues/1408

Installing navidrome throws "Unit navidrome.service is not loaded properly: Exec format error."

While installing navidrome I am getting this error:
hardik:/etc/systemd/system$ sudo systemctl start navidrome.service
Failed to start navidrome.service: Unit navidrome.service is not loaded properly: Exec format error.
See system logs and 'systemctl status navidrome.service' for details.
The content of navidrome.service is given below:-
navidrome.service
[Unit]
Description=Navidrome Music Server and Streamer compatible with Subsonic/Airsonic
After=remote-fs.target network.target
AssertPathExists=/var/lib/navidrome
[Install]
WantedBy=multi-user.target
[Service]
User=<user>
Group=<group>
Type=simple
ExecStart=/opt/navidrome/navidrome --configfile "/var/lib/navidrome/navidrome.toml"
WorkingDirectory=/var/lib/navidrome
TimeoutStopSec=20
KillMode=process
Restart=on-failure
# See https://www.freedesktop.org/software/systemd/man/systemd.exec.html
DevicePolicy=closed
NoNewPrivileges=yes
PrivateTmp=yes
PrivateUsers=yes
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
SystemCallFilter=~#clock #debug #module #mount #obsolete #reboot #setuid #swap
ReadWritePaths=/var/lib/navidrome
# You can uncomment the following line if you're not using the jukebox This
# will prevent navidrome from accessing any real (physical) devices
#PrivateDevices=yes
# You can change the following line to `strict` instead of `full` if you don't
# want navidrome to be able to write anything on your filesystem outside of
# /var/lib/navidrome.
ProtectSystem=full
# You can uncomment the following line if you don't have any media in /home/*.
# This will prevent navidrome from ever reading/writing anything there.
#ProtectHome=true
# You can customize some Navidrome config options by setting environment variables here. Ex:
#Environment=ND_BASEURL="/navidrome"
Why am I getting the error and how do I fix it?
I had the same error when I was trying to start the service on my raspberry pi 3 using navidrome_0.47.5_Linux_arm64.tar.gz. When I replaced it with files from navidrome_0.47.5_Linux_armv7.tar.gz, everything went fine. It's likely that you might be trying to run the executable with a wrong architecture.
Also I believe that User and Group should contain the actual user and group that you chose here:
sudo install -d -o <user> -g <group> /opt/navidrome
sudo install -d -o <user> -g <group> /var/lib/navidrome

Windows 10 Docker Sitespeed.io error: "$(pwd)" includes invalid characters for a local volume name

I am very new to docker so this may be a simple fix.
I am trying to get an instance of sitespeed.io up and running by following their docs on a Windows 10 machine which has a default install of Docker - not using Windows containers, C is shared.. Install steps: https://www.sitespeed.io/documentation/sitespeed.io/installation/#windows-1
Step 1 works fine.
C:\Users\Vicky> docker pull sitespeedio/sitespeed.io
Step 2 does not.
C:\Users\Vicky> docker run --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io https://www.sitespeed.io -b firefox
This results in an error that I am looking for help with. Specifically:
C:\WINDOWS\system32>docker run --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io https://www.sitespeed.io -b firefox
docker: Error response from daemon: create $(pwd): "$(pwd)" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'docker run --help'.
So running the command as per suggestion from Tarun: https://stackoverflow.com/users/2830850/tarun-lalwani works.
docker run --rm -v "%cd%":/sitespeed.io sitespeedio/sitespeed.io http: //www.yahoo.com -b firefox (Space added to URL so you can see the full string.)
Now it produces the following error...
docker run --rm -v "%cd%":/sitespeed.io sitespeedio/sitespeed.io https://www.yahoo.com -b firefox
Google Chrome 60.0.3112.78
Mozilla Firefox 54.0
[2017-09-13 22:58:56] INFO: Versions OS: linux 4.9.41-moby nodejs: v6.11.1 sitespeed.io: 5.5.0 browsertime: 1.6.1 coach: 0.36.0
[2017-09-13 22:58:57] INFO: Starting firefox for analysing https://www.yahoo.com 3 time(s)
[2017-09-13 22:58:57] Testing url https://www.yahoo.com run 1
[2017-09-13 22:59:39] Catched a WebDriverError [Reached error page: about:neterror?e=dnsNotFound&u=https%3A//www.yahoo.com/&c=UTF-8&f=regular&d=Firefox%20can%E2%80%99t%20find%20the%20server%20at%20www.yahoo.com.]. Try one more time.WebDriverError: Reached error page: about:neterror?e=dnsNotFound&u=https%3A//www.yahoo.com/&c=UTF-8&f=regular&d=Firefox%20can%E2%80%99t%20find%20the%20server%20at%20www.yahoo.com.
[2017-09-13 23:00:20] WebDriverError:WebDriverError: Reached error page: about:neterror?e=dnsNotFound&u=https%3A//www.yahoo.com/&c=UTF-8&f=regular&d=Firefox%20can%E2%80%99t%20find%20the%20server%20at%20www.yahoo.com.
[2017-09-13 23:00:20] Could not load URLUrlLoadError: Failed to load https://www.yahoo.com, cause: Reached error page: about:neterror?e=dnsNotFound&u=https%3A//www.yahoo.com/&c=UTF-8&f=regular&d=Firefox%20can%E2%80%99t%20find%20the%20server%20at%20www.yahoo.com.
[2017-09-13 23:00:21] ERROR: https://www.yahoo.com generated the following error in Browsertime UrlLoadError: Failed to load https://www.yahoo.com
at BrowsertimeError (/usr/src/app/node_modules/browsertime/lib/support/errors.js:5:5)
at UrlLoadError (/usr/src/app/node_modules/browsertime/lib/support/errors.js:19:5)
at getUrl.then.then.catch.catch.e (/usr/src/app/node_modules/browsertime/lib/core/seleniumRunner.js:175:15)
From previous event:
at SeleniumRunner.loadAndWait (/usr/src/app/node_modules/browsertime/lib/core/seleniumRunner.js:173:13)
at Promise.resolve.tap.tap.tap.tap.tap (/usr/src/app/node_modules/browsertime/lib/core/engine.js:281:27)
From previous event:
at runIteration (/usr/src/app/node_modules/browsertime/lib/core/engine.js:281:10)
at Promise.reduce (/usr/src/app/node_modules/browsertime/lib/core/engine.js:357:27)
From previous event:
at Promise.resolve.tap.tap.tap.tap.result (/usr/src/app/node_modules/browsertime/lib/core/engine.js:354:17)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
From previous event:
at Engine.run (/usr/src/app/node_modules/browsertime/lib/core/engine.js:353:8)
at engine.start.then (/usr/src/app/lib/plugins/browsertime/analyzer.js:95:26)
From previous event:
at Object.analyzeUrl (/usr/src/app/lib/plugins/browsertime/analyzer.js:95:8)
at storageManager.createDirForUrl.then.then (/usr/src/app/lib/plugins/browsertime/index.js:179:32)
at /usr/src/app/node_modules/mkdirp/index.js:30:20
at FSReqWrap.oncomplete (fs.js:123:15)
From previous event:
at Object.processMessage (/usr/src/app/lib/plugins/browsertime/index.js:179:12)
at queue.process.message (/usr/src/app/lib/support/queueHandler.js:183:32)
at drainItem (/usr/src/app/node_modules/concurrent-queue/index.js:92:21)
at Immediate.drain (/usr/src/app/node_modules/concurrent-queue/index.js:73:84)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
[2017-09-13 23:00:21] ERROR: TypeError: Cannot read property 'getItems' of undefined
at Object.summarize (/usr/src/app/lib/plugins/assets/aggregator.js:103:49)
at Object.processMessage (/usr/src/app/lib/plugins/assets/index.js:40:36)
at queue.process.message (/usr/src/app/lib/support/queueHandler.js:183:32)
at drainItem (/usr/src/app/node_modules/concurrent-queue/index.js:92:21)
at Immediate.drain (/usr/src/app/node_modules/concurrent-queue/index.js:73:84)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
[2017-09-13 23:00:21] INFO: Render HTML for 1 page(s)
[2017-09-13 23:00:21] INFO: HTML stored in /sitespeed.io/sitespeed-result/www.yahoo.com/2017-09-13-22-58-56
[2017-09-13 23:00:21] INFO: Finished analysing https://www.yahoo.com
Try use "." instead which means to use the current directory. The updated example then looks like:
docker run --rm -v .:/sitespeed.io sitespeedio/sitespeed.io https://www.yahoo.com -b firefox
It is because in your present working directory the command is unable to find the folder "sitespeed.io". Run the command like below:
docker run --rm -v "$(pwd)" sitespeedio/sitespeed.io https://www.sitespeed.io -b firefox
And if you are using a windows machine, try doing the below
docker run --rm -v "${pwd}":/sitespeed.io sitespeedio/sitespeed.io https://www.sitespeed.io -b firefox
Please try below :
C:\Users\Vicky> docker run --shm-size=1g --rm -v "$(pwd)":/Users/Vicky sitespeedio/sitespeed.io https://www.sitespeed.io -b firefox
You need to provide the present working directory path in place of sitespeed.io
C:\Users\Vicky> docker run --shm-size=1g --rm -v "$(pwd)":/Users/Vicky sitespeedio/sitespeed.io https://www.sitespeed.io -b firefox

Static Go Binaries w/ Docker - Entrypoint Not Found

I used Static Go Binaries with Docker on OSX by Nicola Paolucci to try to use static Go binary w/ Docker. I believe I followed every step correctly, but when I run the final image, I get the following error response from Docker.
NOTE The name of my service and executable are netverify
docker: Error response from daemon: Container command '/netverify' not found or does not exist..
My Dockerfile.static looks like the following...
#Create a minimal container to run a Golang static binary
FROM tianon/true
ADD netverify /
EXPOSE 8282
CMD ["/netverify"]
My Dockerfile.build looks like the following...
FROM golang
ADD Makefile /
WORKDIR /
RUN make setup
ADD . /go/src/github.com/eirwin/netverify
RUN make buildgo
CMD ["/bin/bash"]
My Makefile is the following...
GOCMD = go
GOBUILD = $(GOCMD) build
GOGET = $(GOCMD) get -v
GOCLEAN = $(GOCMD) clean
GOINSTALL = $(GOCMD) install
GOTEST = $(GOCMD) test
.PHONY: all
all: build
setup:
$(GOGET) github.com/gorilla/mux
buildgo:
GOOS=linux $(GOBUILD) -o netverify ./go/src/github.com/eirwin/netverify
builddocker:
docker build -t eirwin/netverify -f ./Dockerfile.build .
docker run -t eirwin/netverify /bin/true
docker cp `docker ps -q -n=1`:/netverify .
chmod 755 ./netverify
docker build --rm=true --tag=eirwin/netverify -f Dockerfile.static .
run: builddocker
docker run -p 8282:8282 eirwin/netverify
For the purpose of this post, lets assume I have the following as my golang application.
func main() {
router := mux.NewRouter()
router.HandleFunc("/ping", api.PingHandler).Methods("GET")
http.ListenAndServe(":8282", router)
}
When I run Make run everything seems to work except for when the image is ran.
I can see that the image builds correctly at ~8.5MB
eirwin/netverify latest eae16e146b91 3 seconds ago 8.63 MB
But when If docker run -p 8282:8282 eirwin/netverify is ran I get the following error...
docker: Error response from daemon: Container command '/netverify' not found or does not exist..
The go static build in your makefile is missing some options.
buildgo:
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s" -a -installsuffix cgo -o netverify ./go/src/github.com/eirwin/netverify
The build process can capture the container ID to avoid timing issues.
Separate the tags for build and binary images.
builddocker:
docker build -t eirwin/netverify-build -f ./Dockerfile.build .
CID=$$(docker create eirwin/netverify-build); \
docker cp $$CID:/netverify .; \
docker rm $$CID
chmod 755 ./netverify
docker build --rm=true --tag=eirwin/netverify -f Dockerfile.static .
Your binary Dockerfile.static can start with the scratch blank image.
FROM scratch

Resources