How do I test an IronWorker task locally using the CLI? - ironworker

How do I test an IronWorker task locally using the CLI?

iron_worker run worker_name -p '{"foo":"bar","baz":[1,2,3]}'
where optional "-p" flag - payload

Assuming you have Docker installed you can also run your worker locally using a Docker command:
$ docker run --rm -v "$(pwd)":/worker -w /worker iron/php sh -c 'php name_of_worker.php'
Just make sure your Docker Quickstart Terminal is up and running.
If it works on Docker then it will work on IronIO. As stated in the Iron docs here.

Related

docker run mysql images but it terminate automaticly

I'm just using docker for first time and I copy it on the internet
This is my file
Dockerfile
FROM mysql:oracle
COPY dbscript.sql /docker-entrypoint-initdb.d/
and I build it with this command
docker build -t mysqllab
after built I run it
docker run -d --name mysqllabtest -e MYSQL_ROOT_PASSWORD='abc123' mysqllab
it's run and get the message of container id, so I run
docker ps
to see what my container is running but it's don't have this container, I try it again with fast docker ps so I see it run for 4 seconds and terminate
What Can I do with this?
I just use
docker logs mysqllabtest
for check something wrong it about MySQL script so after I edited it It's works! thanks #Hans Kilian for tell me this command

docker: invalid reference format. See 'docker run --help'

I am trying to serving my model using TensorFlow with docker. I downloaded Docker for windows and tried the code as per the documentation.
!docker pull tensorflow/serving
!git clone https://github.com/tensorflow/serving
TESTDATA="/serving/tensorflow_serving/servables/tensorflow/testdata"
Above code worked fine .But when i tried below code
!docker run -t --rm -p 8501:8501,-v "TESTDATA/saved_model_half_plus_two_cpu:/models/half_plus_two",-e MODEL_NAME=half_plus_two,tensorflow/serving
It is giving below error.
docker: invalid reference format.See 'docker run --help'..
Any idea guys please help.
#BSP This worked for me:
docker run -t --rm -p 8501:8501 -v "$testdata/saved_model_half_plus_two_cpu:/models/half_plus_two" -e "MODEL_NAME=half_plus_two" tensorflow/serving

Docker container bash terminal is irresponsive

I have a MySQL instance running on a docker container. I am trying to access the bash terminal by running "docker exec -t myContainerID /bin/bash" for the container so that I can check into my MySQL and see if the setup is correct. Although after accessing the bash terminal, any command I run is irresponsive. Even something as simple as ls. Is there any way to resolve this or know what might be causing the problem? Thanks.
You seem to be missing the -i option, try running: docker exec -ti CONTAINER_ID /bin/bash
And just FYI:
--interactive , -i Keep STDIN open even if not attached
--tty , -t Allocate a pseudo-TTY

How to make mysql and php work together and without show the database password

start mysql container
$ docker run --name mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql
Connect to MySQL and manually create new database
$ docker run -it --link mysql:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
link the database and start php container
$ docker run -d --link mysql:mysql --name myapp -v "$PWD":/var/www/html -p 80:80 php:5.6-apache
first question:
When access my php website: http://localhost/index.php, I got below error:
Fatal Error: Mysql is not supported in your PHP, recompile and try again.
Here is the configure command shows in phpinfo page, seems mysql module has been included in compile.
Configure Command './configure' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--with-apxs2' '--disable-cgi' '--enable-mysqlnd' '--with-curl' '--with-openssl' '--with-readline' '--with-recode' '--with-zlib'
Are there anything missed in official php image?
second question:
When access http://localhost/info.php, I can see phpinfo page.
But it also shows database password in session "Environment":
MYSQL_ENV_MYSQL_ROOT_PASSWORD my-secret-pw
and in session "PHP Variables"
_ENV["MYSQL_ENV_MYSQL_ROOT_PASSWORD"] my-secret-pw
So how to hide the password in phpinfo()?
I assume you're trying to run phplist in a docker environment.
The message you're seeing (Fatal Error: Mysql is not supported in your PHP, recompile and try again.) is a phplist error message hardcoded in both the ./admin/mysql.inc and ./admin/mysqli.inc files.
This message is displayed upon check for the mysql_connect and mysqli_connect functions being present. You are seeing this message because the functions are not present in your environment.
You have to find out what package offers this functionality and either install it on your docker image, or build a new docker image with this support present.
The official PHP docker image is based on Debian, which offers the php5-mysql package. This is not present in the docker image, so you install this package using apt-get, then use docker-php-ext-install, docker-php-ext-configure and docker-php-ext-enable to enable the mysql and mysqli extensions.

How to build sidekiq and rails image with docker?

I am trying another way to build a rails application into a docker image.
The structure of my services:
redis -- from official docker hub registry
fluentd -- from official docker hub registry
mysql -- from official docker hub registry
sidekiq -- build myself(maybe there isn't a official image for this)
web -- build myself
I created two Dockerfiles like:
Dockerfile.sidekiq
Dockerfile.web
Dockerfile.sidekiq
FROM ruby:2.2.2
ENV APP_HOME /myapp
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ADD Gemfile $APP_HOME/Gemfile
ADD Gemfile.lock $APP_HOME/Gemfile.lock
ADD config/sidekiq.yml $APP_HOME/config/sidekiq.yml
ADD init_sidekiq.sh $APP_HOME/
RUN export LANG=C.UTF-8 && bundle install
ADD . $APP_HOME
CMD ["sh", "init_sidekiq.sh"]
init_sidekiq.sh
#!/bin/sh
bundle exec sidekiq -C config/sidekiq.yml
Dockerfile.web
FROM rails:4.2.1
ENV APP_HOME /myapp
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ADD Gemfile $APP_HOME/Gemfile
ADD Gemfile.lock $APP_HOME/Gemfile.lock
ADD init_web.sh $APP_HOME/
RUN export LANG=C.UTF-8 && bundle install
ADD . $APP_HOME
CMD ["sh", "init_web.sh"]
init_web.sh
#!/bin/sh
bundle exec rake db:create db:migrate
bundle exec rails server -b 0.0.0.0
Use them I built two images:
myapp_web
myapp_sidekiq
Then run these containers:
$ docker run --name redis -d redis
$ docker run --name fluentd -d -p 24224:24224 fluent/fluentd
$ docker run --name mysql -e MYSQL_ROOT_PASSWORD=my_password -d mysql
Make env.list
RAILS_ENV=production
DATABASE_URL=mysql2://root:my_password#172.17.0.4/myapp?checkout_timeout=20000
Go on run these containers:
$ docker run --name web -d -p 3000:3000 --link mysql:mysql --env-file ./env.list myapp_web
$ docker run --name sidekiq -d --link mysql:mysql --env-file ./env.list myapp_sidekiq
The result:
redis -- success
fluentd -- success
mysql -- success
web -- success
sidekiq -- failure
The sidekiq log:
$ docker logs sidekiq
Unknown database 'myapp'
/usr/local/bundle/gems/activerecord-4.2.1/lib/active_record/connection_adapters/mysql2_adapter.rb:23:in `rescue in mysql2_connection'
I used the same method both web and sidekiq to connect mysql. I believe that in the mysql container there exists a myapp database. But why it can't find it?
Is it a wrong way to make them been two containers? How to run sidekiq correctly?
I think the problem there is how are you connecting to redis? The message appears to come from sidekiq and somehow it can't connect to your redis server. (and I think trying to connect to some bogus db server/database)
So I think you need to link your sidekiq container to both your db container and also your redis container.
docker run --name sidekiq -d --link mysql:mysql --link redis:redis --env-file ./env.list myapp_sidekiq
Also, would be nice if you can share your env.list