title: Running word count example on docker
body: <p>I have a container with hadoop-2.7.4 installed on it. I run this container with this command:</p>
  
  <pre><code>sudo docker run -it -v somewhere/project/:/root/project/ --net=host --name hadoop -p 22:22 hadoop-img
  </code></pre>
  
  <p>I already changed the files below,</p>
  
  <p><strong>~/.bashrc</strong></p>
  
  <pre><code>...
  #hadoop variables, start
  export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
  export HADOOP_INSTALL=/opt/hadoop-2.7.4
  export PATH=$PATH:$HADOOP_INSTALL/bin
  export PATH=$PATH:$HADOOP_INSTALL/sbin
  export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
  export HADOOP_COMMON_HOME=$HADOOP_INSTALL
  export HADOOP_HDFS_HOME=$HADOOP_INSTALL
  export YARN_HOME=$HADOOP_INSTALL
  export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
  export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
  #hadoop variables, end
  </code></pre>
  
  <p><strong>core-site.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="configuration.xsl"?&gt;
  &lt;!--
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
  
      http://www.apache.org/licenses/LICENSE-2.0
  
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License. See accompanying LICENSE file.
  --&gt;
  
  &lt;!-- Put site-specific property overrides in this file. --&gt;
  
  &lt;configuration&gt;
  &lt;property&gt;
  &lt;name&gt;hadoop.tmp.dir&lt;/name&gt;
  &lt;value&gt;/app/hadoop/tmp&lt;/value&gt;
  &lt;description&gt;A base for other temporary directories.&lt;/description&gt;
  &lt;/property&gt;
  &lt;property&gt;
  &lt;name&gt;fs.default.name&lt;/name&gt;
  &lt;value&gt;hdfs://localhost:22&lt;/value&gt;
  &lt;description&gt;The name of the default file system. A URI whose
  scheme and authority determine the FileSystem implementation. The
  uri's scheme determines the config property (fs.SCHEME.impl) naming
  the FileSystem implementation class. The uri's authority is used to
  determine the host, port, etc. for a filesystem.&lt;/description&gt;
  &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>hadoop-env.sh</strong></p>
  
  <pre><code>...
  export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
  ...
  </code></pre>
  
  <p><strong>hdfs-site.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="configuration.xsl"?&gt;
  &lt;!--
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
  
      http://www.apache.org/licenses/LICENSE-2.0
  
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License. See accompanying LICENSE file.
  --&gt;
  
  &lt;!-- Put site-specific property overrides in this file. --&gt;
  
  &lt;configuration&gt;
  &lt;property&gt;
  &lt;name&gt;dfs.replication&lt;/name&gt;
  &lt;value&gt;0&lt;/value&gt;
  &lt;description&gt;Default block replication.
  The actual number of replications can be specified when the file is created.
  The default is used if replication is not specified in create time.
  &lt;/description&gt;
  &lt;/property&gt;
  &lt;property&gt;
  &lt;name&gt;dfs.namenode.name.dir&lt;/name&gt;
  &lt;value&gt;file:/usr/local/hadoop_store/hdfs/namenode&lt;/value&gt;
  &lt;/property&gt;
  &lt;property&gt;
  &lt;name&gt;dfs.datanode.data.dir&lt;/name&gt;
  &lt;value&gt;file:/usr/local/hadoop_store/hdfs/datanode&lt;/value&gt;
  &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>mapred-site.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="configuration.xsl"?&gt;
  &lt;!--
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
  
      http://www.apache.org/licenses/LICENSE-2.0
  
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License. See accompanying LICENSE file.
  --&gt;
  
  &lt;!-- Put site-specific property overrides in this file. --&gt;
  
  &lt;configuration&gt;
  &lt;property&gt;
  &lt;name&gt;mapred.job.tracker&lt;/name&gt;
  &lt;value&gt;localhost:22&lt;/value&gt;
  &lt;description&gt;The host and port that the MapReduce job tracker runs
  at. If "local", then jobs are run in-process as a single map
  and reduce task.
  &lt;/description&gt;
  &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I have a WordCount example and I am going to run it with a dataset. when I start hadoop with <code>./start-all.sh</code> I got this:</p>
  
  <pre><code>This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
  17/10/11 10:04:34 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  Starting namenodes on [localhost]
  localhost: ssh: connect to host localhost port 22: Connection refused
  localhost: ssh: connect to host localhost port 22: Connection refused
  Starting secondary namenodes [0.0.0.0]
  0.0.0.0: ssh: connect to host 0.0.0.0 port 22: Connection refused
  17/10/11 10:04:37 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  starting yarn daemons
  starting resourcemanager, logging to /opt/hadoop-2.7.4/logs/yarn--resourcemanager-saeed-X550CC.out
  localhost: ssh: connect to host localhost port 22: Connection refused
  </code></pre>
  
  <p>why I always get this error??!</p>
  
  <blockquote>
    <p>connect to host localhost port 22: Connection refused</p>
  </blockquote>